I am using one gridview to display company name as text column and approval column as checkboxfield. If checked I have to approve corresponding company to our list.In the gridview control's Rowcommand event if "e.commandName" is update I have to update.For
this purpose I need to get the checkbox status. How can I access checkboxfield value there. Please help me. It will great kind of yoy.
With regards
Faisal
highlight
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Don't forget to click "Mark as Answer" on the post that helped you.
Here I am using Checkbox field as column not checkbox control under template field. I had tried to add ID property, but checkbox field doesn't support to set ID attribute. I converted checkbox field column to template and solved my issue. But still I wanted
to know If we use Checkbox field how can we access its propery at run time. could you please help me?, I will be gratefull to you.
Thanks & regards
Faisal
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Don't forget to click "Mark as Answer" on the post that helped you.
faisalnk
Member
452 Points
110 Posts
How to access CheckBoxField value of gridview control
Sep 06, 2006 10:15 AM|LINK
Hi ,
I am using one gridview to display company name as text column and approval column as checkboxfield. If checked I have to approve corresponding company to our list.In the gridview control's Rowcommand event if "e.commandName" is update I have to update.For this purpose I need to get the checkbox status. How can I access checkboxfield value there. Please help me. It will great kind of yoy.
With regards
Faisal
highlight
Don't forget to click "Mark as Answer" on the post that helped you.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Thanks & Regards
Faisal. N
Crouchin9Tig...
Participant
1205 Points
249 Posts
Re: How to access CheckBoxField value of gridview control
Sep 06, 2006 03:51 PM|LINK
Try this:
Dim row As GridViewRow = CType(CType(e.CommandSource, Control).Parent.Parent, GridViewRow)
Dim chkBox As checkbox = CType(row.FindControl("yourCheckBoxControl"), checkbox)
This should give you access to your control.
faisalnk
Member
452 Points
110 Posts
Re: How to access CheckBoxField value of gridview control
Sep 07, 2006 06:45 AM|LINK
Hi Crouchin9Tiger,
Thanks a lot for your immediate reply. I couldn't use following code since checkboxfiled doen't have ID attribute.
Dim chkBox As checkbox = CType(row.FindControl("yourCheckBoxControl"), checkbox)
Do you have any other solution for this?
Thnks in advance for your reply
With regards
Faisal
Don't forget to click "Mark as Answer" on the post that helped you.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Thanks & Regards
Faisal. N
Crouchin9Tig...
Participant
1205 Points
249 Posts
Re: How to access CheckBoxField value of gridview control
Sep 07, 2006 01:39 PM|LINK
faisalnk
Member
452 Points
110 Posts
Re: How to access CheckBoxField value of gridview control
Sep 14, 2006 03:56 PM|LINK
Hi,
Here I am using Checkbox field as column not checkbox control under template field. I had tried to add ID property, but checkbox field doesn't support to set ID attribute. I converted checkbox field column to template and solved my issue. But still I wanted to know If we use Checkbox field how can we access its propery at run time. could you please help me?, I will be gratefull to you.
Thanks & regards
Faisal
Don't forget to click "Mark as Answer" on the post that helped you.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Thanks & Regards
Faisal. N
Crouchin9Tig...
Participant
1205 Points
249 Posts
Re: How to access CheckBoxField value of gridview control
Sep 14, 2006 04:06 PM|LINK
Try doing something like this:
Dim r As GridViewRow
For Each r In grd.Rows
Dim chkBox As CheckBox = CType(r.Cells(0).Controls(1), CheckBox)
Next
You may have to play around with the index inside the control property depending on wether or not you have any other controls in that column.
Hope this helps.
varsha_sinya...
Member
5 Points
1 Post
Re: How to access CheckBoxField value of gridview control
Oct 07, 2006 01:45 PM|LINK
noshad
Member
5 Points
1 Post
Re: How to access CheckBoxField value of gridview control
Oct 11, 2006 11:01 AM|LINK
[quote user="varsha_sinyal"]How to access value of a column whose visible property is set to false in grid view control ?
You can access the value of the control used in GridView by:
foreach (GridViewRow gridRow in GridView.Rows)
{
CheckBox chk = (CheckBox)gridRow.FindControl("yourChkBox");
}
and you can access the column by its index :
GridView.Columns[4].Visible = true;
Tobby
Member
2 Points
1 Post
Re: How to access CheckBoxField value of gridview control
Aug 20, 2007 10:02 PM|LINK
Try
Dim ck as CheckBox = CType(GridView1.Rows(0).Cells(0).Controls(0), CheckBox)
If ck.Checked = True Then
YourCheckBox.Checked = True
Else
YourCheckBox.Checked = False
End If
rathbird
Member
2 Points
1 Post
Re: How to access CheckBoxField value of gridview control
Aug 02, 2009 03:54 PM|LINK
Here's how I do it:
to access the checked property of a asp:CheckBoxField in a gridview:
cbActive.Checked = ((CheckBox)GridView1.Rows[r].Cells[14].Controls[0]).Checked;
where r is my rowIndex.