theunknownknight
MIS
Question Title: Reading Dynamic Checkboxes from Datagrid
Author: theunknownknight
Points: 125
Date: 01/07/2004 12:05PM PST
I just finished this article on dotnetbips called "Creating DataGrid Templated Columns Dynamically - Part I"
Heres the code in the article:
string connstr = @"Integrated Security=SSPI;User ID=sa;Initial Catalog=Northwind;Data Source=MyServer\NetSDK";
SqlConnection cnn=new SqlConnection(connstr);
SqlDataAdapter da=new SqlDataAdapter("select * from employees", cnn);
DataSet ds=new DataSet();
da.Fill(ds, "employees"
ITemplate temp= Page.LoadTemplate("webusercontrol1.ascx"
TemplateColumn tc=new TemplateColumn();
tc.HeaderText = "Last Name";
tc.ItemTemplate = temp;
DataGrid1.Columns.Add(tc);
DataGrid1.DataSource = ds;
DataGrid1.DataMember = "employees";
DataGrid1.DataBind();
------------------------------------------------
<%@ Control Language="C#" %>
<asp:label ID="label1" Runat="server" text='<%# Databinder.Eval ((DataGridItem)Container).DataItem,"lastname"%>'>
</asp:label>
--------------------------------------------------
I thought it was great. I have a question, however, how do you read from the checkboxes in code. I'm trying to use the code that was provided and add the functionality of selecting rows from the datagrid. The checkboxes in the templated column are not being recognized. Can someone please show me how to do this.
Here is the link to the article
Author: theunknownknight
Points: 125
Date: 01/07/2004 12:05PM PST
I just finished this article on dotnetbips called "Creating DataGrid Templated Columns Dynamically - Part I"
Heres the code in the article:
string connstr = @"Integrated Security=SSPI;User ID=sa;Initial Catalog=Northwind;Data Source=MyServer\NetSDK";
SqlConnection cnn=new SqlConnection(connstr);
SqlDataAdapter da=new SqlDataAdapter("select * from employees", cnn);
DataSet ds=new DataSet();
da.Fill(ds, "employees"
ITemplate temp= Page.LoadTemplate("webusercontrol1.ascx"
TemplateColumn tc=new TemplateColumn();
tc.HeaderText = "Last Name";
tc.ItemTemplate = temp;
DataGrid1.Columns.Add(tc);
DataGrid1.DataSource = ds;
DataGrid1.DataMember = "employees";
DataGrid1.DataBind();
------------------------------------------------
<%@ Control Language="C#" %>
<asp:label ID="label1" Runat="server" text='<%# Databinder.Eval ((DataGridItem)Container).DataItem,"lastname"%>'>
</asp:label>
--------------------------------------------------
I thought it was great. I have a question, however, how do you read from the checkboxes in code. I'm trying to use the code that was provided and add the functionality of selecting rows from the datagrid. The checkboxes in the templated column are not being recognized. Can someone please show me how to do this.
Here is the link to the article