Checkbox changed event in gridview-help

Joined
Jun 28, 2006
Messages
2
Reaction score
0
i have a aspx page where a gridview is placed ( list.aspx ) , in the code behind i am passing the gridview to a helper function ( in Helper.cs ) where the gridview has to be populated. i am building the gridview rows at runtime like below.

/* template to insert the check box in the gridview
public class CheckTemplate : ITemplate
{
public void InstantiateIn(System.Web.UI.Control container)
{
CheckBox ch = new CheckBox();
ch.ID = "chkUser";
ch.AutoPostBack = true;
container.Controls.Add (ch);
}
}

DataTable hTable;
DataRow hRow;

BoundField hDataField;

hTemplateField = new TemplateField();
hTemplateField.HeaderText = "Select";
hTemplateField.ItemTemplate = new CheckTemplate();
hResults.Columns.Add(hTemplateField);

hDataField = new BoundField();
hDataField.HeaderText = "First Name";
hDataField.ItemStyle.Wrap = false;
hDataField.DataField = "FirstName";
hResults.Columns.Add(hDataField);

hDataField = new BoundField();
hDataField.HeaderText = "Last Name";
hDataField.DataField = "LastName";
hDataField.ItemStyle.Wrap = false;
hResults.Columns.Add(hDataField);

Here i am running a stored procedure and for each row i am getting the values and populating the gridview like below.

hDataSet = cmd.ExecuteQuery("...");

hRow = hTable.NewRow();

hRow[0] = hDataSet.GetFieldValueByName("FirstName");
hRow[1] = hDataSet.GetFieldValueByName("LastName");

hTable.Rows.Add(hRow);

hView = new DataView(hTable);

hResults.DataSource = hView;
hResults.DataBind();

i wanted to know how to handle the checkchanged event for this as the grid is being populated in a different helper function :shock:
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top