471,055 Members | 1,956 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,055 software developers and data experts.

datagrid and checkboxes

Hi!
I have a Datagrid with a column that is a checkbox.
Something like this:

<asp:datagrid id="dg2" runat="server">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:CheckBox ID="chkSelection" Runat="server" />
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

in an aspx. When I load de aspx i bind it with a datatable
so i get a datagrid with the columns and rows of the
datatable and the first column is a checkbox.
I now want to get the values of the rows in wich the
checkbok is checked.

I tried something like:

foreach(DataGridItem dgit in dg2.Items)
{
chkse = dgit.FindControl("chkSelection") as CheckBox;
if (chkse.Checked)
{
//code in here
}

}

so far so good. I've read that i can use another
FindControl to get the values, but I have to do a cast
(CType in VB although I am using c#) to the control as a
label and all I get is null.
Is there a way to get all the values of the row. Like an
iterator for that row in that specific DataItem?

Thank You
Jul 21 '05 #1
0 901

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Mortar | last post: by
1 post views Thread by kannadasan | last post: by
7 posts views Thread by DJ Dev | last post: by
2 posts views Thread by Mortar | last post: by
7 posts views Thread by Jaime Stuardo | last post: by
3 posts views Thread by GatorBait | last post: by
7 posts views Thread by rn5a | last post: by
5 posts views Thread by rn5a | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.