iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
I'm having trouble retrieving the value of a checkbox in a WebGrid in both "Template" and "Checkbox" column scenarios. I have a checkbox that I don't want bound to any data; it exists as a flag that indicates that the user would like to save some data that is contained in the rows that they check. Then, I have a button on the page that, when clicked, is supposed to allow the retrieval of the checked rows. But, when I handle the click event and loop through the rows, I can't get the data. If I use a CheckBox column, the "Text" and "Value" properties are always "0" even if the CheckBox is checked. In "Template" column scenarios, when I try to find the CheckBox via "GetTemplate.FindControl("chk"), the control is not found.
So, what is the recommended way of accomplishing this? I want a CheckBox as the first column of each row and the user can select some rows and, when they click a button on the page, I want to retrieve the checked columns? There is probably just something small that I am missing.
Brad
Hello Brad,
When at template Column, the ID of checkbox has been changed. You could not get "chk" in clientside. If you try to view source at the browser and search for "chk", you should be able to find the changed id.Also, I think that you wanted to get the checked rows, not checked column in your scenario.We have a WebGrid Sample >> PreserveCheckedRows.aspx. In order to do this, you will need to use our ISRowChecker feature. You can use this sample to retrieve the checked rows value from server side.
Or you can use my attached sample as reference. I showed how to get checked rows via client side and server side. Hope this helps.
Regards,Handy
Hi Handy,
I don't quite understand this example. I would have expected the GetCheckedRows method to return WebGridRow objects but instead, I get an arraylist of empty strings. I'm not sure what I can do with an arraylist of empty strings. Ultimately, I need to know which rows are checked and then I need to retrieve data from those rows. I don't know if I can accomplish that with this method. Am I overlooking something?
Hi Brad,
It does return on the checked rows. Could you provide your runable sample which replicate this issue? I need it toinvestigate the differences.
Normally, when used GetCheckedRows in ISRowChecker or Multiple selection features, the method shall return the checked or selection rows.So, my question, Do you also use ISRowChecker in your sample?
In my previous sample, I used ISRowChecker and GetCheckedRows() should be able to return the object.
Handy,
Here are the relevant code snippets
<ISWebGrid:WebGridColumn Name="Fasta" Caption="Fasta" ColumnType="CheckBox" IsRowChecker="true" Bound="false" Width="50" />
Dim al As ArrayList = WebGrid1.RootTable.GetCheckedRows()
So I have a grid with a bunch of data and the first column in the grid is a checkbox column with isRowChecker set to "true." I check two rows and click an <asp:Button instance and in the "Click" event handler for that button, I am trying to get the checked rows. When I call "GetCheckedRows," I get an arraylist of empty strings. It should not be too hard to replicate as there is nothing that I am doing that is out of the ordinary from what I can tell.
Thanks,
I am able to get the checked data key values the following way
For Each str As String In WebGrid1.RootTable.GetCheckedRows() Dim row As WebGridRow = Me.WebGrid1.RootTable.Rows.GetRowByKeyValue(str) cList.Add(row.Cells.GetNamedItem("ID").Text.Trim()) Next
The difference was that I didn't have a DataKeyField on my grid and didn't have PersistRowChecker set to True.
So I am all set now on this one.
Thanks for your help.
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname