Checkbox changed event in gridview-help

Discussion in '.NET' started by Vinay.d, Jul 13, 2006.

  1. Vinay.d

    Vinay.d

    Joined:
    Jun 28, 2006
    Messages:
    2
    Location:
    Bangalore
    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: Jul 13, 2006
    Vinay.d, Jul 13, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. tshad
    Replies:
    5
    Views:
    5,976
    Joaquin Corchero
    Mar 15, 2005
  2. st@jpa.co.jp
    Replies:
    1
    Views:
    684
    Rosanne
    Oct 11, 2005
  3. smita
    Replies:
    3
    Views:
    742
  4. shiv

    CheckBox Changed Event Not Firing in DataGrid

    shiv, Jun 18, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    521
  5. mxbrunet
    Replies:
    1
    Views:
    215
Loading...

Share This Page