# c# problem



## sumigizlov (Nov 11, 2009)

i was trying to  add a button column to the windows forms datagridview but i do not know the event that will be fired on clicking the button in asp it is the item command event but there is no such event in windows form datagridview
please help


----------



## krishnandu.sarkar (Nov 11, 2009)

As far i know button_click event will b fired. But for that u need to write the gridview_rowcommand event for that button.

May b I'm wrong. I'm not so sure. I forgot.....!!


----------



## sumigizlov (Nov 11, 2009)

but in case of windows forms datagridview RowCommand is not available it is only available in asp.net


----------



## vamsi360 (Nov 11, 2009)

when you click the button the event is button_click.

When you want to fire the event on page load Page_Load


----------



## sumigizlov (Nov 11, 2009)

i am not asking for regular buttons i am asking for datagridview button column


----------



## krishnandu.sarkar (Nov 11, 2009)

Ya RowCommand is available in ASP.NET. U r in Windows......Sorry I didn't noticed.

So what r u asking? The ques is not clear not even now. As u said what will b the event in ASP.


----------



## sumigizlov (Nov 12, 2009)

yes in asp it is rowcommand but i am asking for windows form


----------



## lucifer_is_back (Nov 12, 2009)

Handle the CellContentClick event of the DataGridView.

Evaluate DataGridView.Columns(e.ColumnIndex).Name to get the name of the column clicked

If it's your button column, then you can get the value of any cell in that row with

DataGridView.CurrentRow.Cells["ColumnNameHere"].Value


----------



## sumigizlov (Nov 12, 2009)

thanks lucifer_is_back your suggestion worked like a charm
but there is still one glitch the first time i click the button it works perfectly but on subsequent click it has no effect


----------



## vamsi360 (Nov 13, 2009)

*msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcellvalueeventargs(VS.85).aspx


----------

