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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP:Button in DataGrid

Status
Not open for further replies.

TomTT

Programmer
Jun 3, 2002
55
US
I have a button in one column of the datagrid and it
executes the correct sub when clicked.

The thing I just can't figure is how to determine what
row the button that was clicked is on.

The arguments sent to the button's sub look like this:

Sub SendUpDate(obj As object, e As EventArgs)

I suspect that I'm mining something obvious here, but I went through 4 pages of post for DataGrid Button and didn't find anything that made the answer obvious.

Thanks for any suggestions.
TT
 
Thanks,

I tried that. I get an error: : 'Item' is not a member of 'System.EventArgs'.

I think it's because of the arguments attached to an ASP:Button.

I tried using (Obj As Object, e As DataGridSortCommandEventArgs) as the argument to the button handler, but that caused an error as well.

I think the problem is in the arguments I've used for the handler. They don't include datagrid row information.

I can use ButtonColumn instead, but am having a tough time getting style attributes to take.

TT
 
The ItemCommand event should fire, when you click on a button in the grid. Therefore, it looks like the arguments in your event handler are wrong. Should be like this:
Code:
private void myGrid_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
   DataGridItem myItem = e.Item;		
}

private void InitializeComponent()
{    
this.myGrid.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.myGrid_ItemCommand);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top