Last post Apr 27, 2008 03:28 PM by abhilashca
Jun 22, 2007 04:13 AM|enghsiang|LINK
Can someone please teach me how to add a checkbox in gridview?
i added from the add new columns,but the checkbox is not fuctioning when i run my page,means it can't be check
can someone please teach me in detail?coz i am new in ASP.Net 2.0 ( Using Visual Studio 2005)
and if possible,i wan to retrieve 1 of the column value of the database row which being checked
can someone teach me this as well?
add a checkbox in Gridview
Jun 22, 2007 05:07 AM|zaladane|LINK
Maybe this article could help you, since the steps are a little bit too complex to explain in a few lines:
Hope it helps
Jun 22, 2007 06:48 AM|wreck_of_u|LINK
you can use TemplateFields for the GridView:
<asp:GridView ID="GridView1" runat="server">
<asp:CheckBox ID="myCheckBox" runat="server" />
Hope this helps:)
Jun 22, 2007 07:07 AM|enghsiang|LINK
Thanks both of u
i already solve my problem.
but still facing another problem.i wish to get the data from the gridview row which being checked
i already open a post which pending for approval.hope u both still can give me some idea.thanks[:)]
Jun 22, 2007 07:18 AM|wreck_of_u|LINK
You may want to convert everything in your GridView into TemplateFields,
after that, you will need to FindControl each of those TemplateField controls in the GridView. Finding a control in a GridView is like this:
Dim myLabel As New Label
ClusterName = GV.Rows(1).Cells(2).FindControl("myLabelinTheGridViewTemplateField")
Ill wait for your pending post, then ill discuss further over there :)
Jun 22, 2007 07:29 AM|enghsiang|LINK
Convert everything into TempleteFields? how to do that?can u tell me detail about that?
this is the post http://forums.asp.net/t/1125079.aspx
thanks for helping [:)]
Jun 22, 2007 03:08 PM|zaladane|LINK
I generally always use templateFields too since i generally don't want things to be line up in columns.
1-in the smart Gridview Tasks that pops open when you drop a gridview on the form , Click on Edit Columns.
2- In the listbox on the top left side , click on TemplateField and push the add button. The field is added to the bottom left list.
3- you can set a couple of the field properties in the right side (the Header text might be a good start.)
4- When you hit ok, the popup is still open, click on Edit Templates... and customize your ItemTemplate. (depending on what you want the EditItemTemplate and the ItemTemplate to look like ).
Apr 27, 2008 03:28 PM|abhilashca|LINK
Pickick a GridView, Connect it to a table.
- Go to the 'Edit-Columns' of the GridView.
- Add a 'template-field'
- Hit OK.
- Now, go to the 'Edit-Template' of the GridView.
- In the 'Column' of the Item-Template, drag-drop a CheckBox
- Check out whats the ID of the CheckBox (must be CheckBox1)
-- That's it.
Now Stop 'Editing Template'
In the Code-Behind use the following code :
foreach (GridViewRow gr in GridView1.Rows)
CheckBox cb = (CheckBox)gr.Cells.FindControl("CheckBox1");
// do ur job here
thus u can access ur checkbox by iterating thru the GridView Rows.
hope this explained alot for u