By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,201 Members | 937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,201 IT Pros & Developers. It's quick & easy.

Retrieving the Value of a checkbox Webserver Control From a Datagrid

P: 8
I am using a checkbox webserver controls in template column of a datagrid webserver Control

I am trying to iterate through the datagid and process rows based on the whether the checkbox for the row is checked or not. However when I attempt to retrieve the selection the checkbox.checked state is false for all rows regardless of whehter the checkbox was checked or not


Here is what I have any assistance appreciated


<Itemtemplate>
<asp:Checkbox id =”checkbox1” runat= “server” autopostback= “true”></asp:Checkbox>
</Item template>

Dim ChBox As CheckBox
intCount As integer



For intCount to Datagrid1.Items.count -1
ChBox = Datagrid1.Items(intCount).Cells(0).Controls(1)

If chBox.checked
‘Do some stuff

Else
‘Do something else

Next
Apr 9 '08 #1
Share this Question
Share on Google+
1 Reply


dip_developer
Expert 100+
P: 648
I am using a checkbox webserver controls in template column of a datagrid webserver Control

I am trying to iterate through the datagid and process rows based on the whether the checkbox for the row is checked or not. However when I attempt to retrieve the selection the checkbox.checked state is false for all rows regardless of whehter the checkbox was checked or not


Here is what I have any assistance appreciated


<Itemtemplate>
<asp:Checkbox id =”checkbox1” runat= “server” autopostback= “true”></asp:Checkbox>
</Item template>

Dim ChBox As CheckBox
intCount As integer



For intCount to Datagrid1.Items.count -1
ChBox = Datagrid1.Items(intCount).Cells(0).Controls(1)

If chBox.checked
‘Do some stuff

Else
‘Do something else

Next

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim chkBox As CheckBox 
  3. ' Go through each row and find a check box 
  4. For Each i As DataGridItem In Datagrid1.Items 
  5. chkBox = CType(i.FindControl("checkbox1"), CheckBox) 
  6.  
  7. If chkBox .Checked Then 
  8. ''Do some stuff 
  9. Else
  10. ''Do something else 
  11. End If 
  12. Next
  13.  
Apr 10 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.