Hi all,
I have a couple of questions in regards to how to retrieve (get) the checkbox state value.
1. I have a an ultrawebgrid with three columns, col1 = Customer ID, col2 = Customer Name, col3=checkbox. (When the checkbox is clicked, it will determine wether an email will be sent out to this customer or not). The checkbox that I used is the one that comes with the webgrid. So all I did was create my column and set the Type="checkbox"
My webgrid has many rows and so from the webgrid and I would like to click on the check box for some customers (records) and not for some. Then I click the Save button to save (update the database) all of the records that have been checked. So on the code behind, how do I determine the value of the Customer ID, Customer Name and the checkboxes that have been selected on the Save button event? My Save button is a regular asp:Button (asp.net 2.0).
2. Would it be better to use an asp:checkbox and embedded inside the ultrawebgrid TemplateColumn?
Please let me know if option one is better or option two is better. Please provide some code sample if possible.
Thanks in advance!
hs2
Use the following code to get the checked columns:
foreach (UltraGridRow row in Grid.Rows)
{ if (row.Cells[columnIndex].Value.ToString().Equals("True")) { // CheckBox is checked }
else
{
// CheckBox is not checked.
} }
Hello Charuk,
I have tried to use the code you suggested above but it doesn't work. I loaded up my webgrid and click on the the checkbox and on the OnActiveCellChange event method and UpdateRowBatch event method, I tried determining the value of the check box but it returns False for the checked checkbox.
What event method did you try to above code on? This way I can use the same event method and try to see if it works and wether it would give me a True value when the checkbox is checked.
Thanks!