Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

two buttonscolumn in datgrid 1

Status
Not open for further replies.

crazyboybert

Programmer
Jun 27, 2001
798
GB
Hi all

I'd like to use a datagrid with two ButtonColumns. Each button will perform a different action on the same row of data from the grid.

How can i distinguish between which button has been pressed on the datagrid row when the ItemCommand event fires?

Ive been having real problems finding any examples of datagrids with multiple button columns anywhere on the any help would be much appreciated.

Thanks

Rob

------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
Add an OnItemCommand to your datagrid. Give it a name such as OnItemCommand="CustomCommand_Click"

On your button, assign a CommandName that corresponds to the string shown below such as CommandName="WriteMessage".

Then in your code behind or function of CustomCommand_Click do the following:

public void CustomCommand_Click(object sender, DataListCommandEventArgs e)
{
if(e.CommandName.ToString() == "WriteMessage")
{
//events go here
}
}

All buttons will be processed through here. You can do specific OnDeleteCommand Events in your datagrid if you give the button a CommandName of "Delete". Same goes for Edit, Update or Cancel.

Hope this helps.

-Tim
 
Thanks Tim

That is exactly what I was looking fro. It's amazing how close you can be to something and just not quite get it.

:eek:)

------------------------------------

On with the dance! let joy be unconfined;
No sleep till morn, when Youth and Pleasure meet
To chase the glowing hours with flying feet.
-Byron

------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top