Add Button column to Grid with Data

Discussion in 'ASP .Net' started by DBLWizard, Apr 4, 2005.

  1. DBLWizard

    DBLWizard Guest

    I am poplating the grid with the following code:

    myCommand = new SqlCommand(sSql, myConn);
    myDA = new SqlDataAdapter();
    myDA.SelectCommand = myCommand;
    myConn.Open();
    myDS = new DataSet();
    myDA.Fill(myDS, "SearchResults");
    grdMatching.DataSource = myDS.Tables["SearchResults"].DefaultView;
    grdMatching.DataBind();
    grdMatching.Visible = true;

    The DataTable that is returned has 2 columns in it. I want to add a
    another column either at the beginning or at the end that I can put a
    button labeled "Select" that will fire a server side event that I can
    act on knowing what row the user has clicked in.

    What is the best was to do this?

    Thanks

    dbl
     
    DBLWizard, Apr 4, 2005
    #1
    1. Advertising

  2. you can right click your datagrid, go to property builder, go to Columns,
    deselect "Create columns automatically at run time", and then define your
    columns. you can add one of the predefined button columns like Select, Edit,
    Update or delete and the use it for your own prposes or define a new one.

    "DBLWizard" <> wrote in message
    news:...
    >I am poplating the grid with the following code:
    >
    > myCommand = new SqlCommand(sSql, myConn);
    > myDA = new SqlDataAdapter();
    > myDA.SelectCommand = myCommand;
    > myConn.Open();
    > myDS = new DataSet();
    > myDA.Fill(myDS, "SearchResults");
    > grdMatching.DataSource = myDS.Tables["SearchResults"].DefaultView;
    > grdMatching.DataBind();
    > grdMatching.Visible = true;
    >
    > The DataTable that is returned has 2 columns in it. I want to add a
    > another column either at the beginning or at the end that I can put a
    > button labeled "Select" that will fire a server side event that I can
    > act on knowing what row the user has clicked in.
    >
    > What is the best was to do this?
    >
    > Thanks
    >
    > dbl
    >
     
    Alejandro Penate-Diaz, Apr 4, 2005
    #2
    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. C Newby
    Replies:
    7
    Views:
    574
    C Newby
    Apr 2, 2004
  2. carlos perez
    Replies:
    0
    Views:
    417
    carlos perez
    Jun 8, 2004
  3. Fernando Lopes

    Add a radio button column in a grid view

    Fernando Lopes, Dec 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    5,883
    Fernando Lopes
    Dec 7, 2004
  4. d shah via .NET 247

    add a column to data grid on fly

    d shah via .NET 247, Mar 15, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    354
    d shah via .NET 247
    Mar 15, 2005
  5. PatLaf

    WebForm Data Grid Button column customization

    PatLaf, Jan 27, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    374
Loading...

Share This Page