Add Button column to Grid with Data

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
 
A

Alejandro Penate-Diaz

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.
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top