Add Button column to Grid with Data

  • Thread starter Thread starter DBLWizard
  • Start date Start date
D

DBLWizard

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
 
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.
 
Back
Top