1. Hey Guest Did you know you can win an Honor 10 phone worth ₹33,000 and an additional ₹70,000 in paytm vouchers, just by replying to some threads and taking part in the discussions happening in the Honor Hub?

    What are you waiting for? Start commenting and start winning! Remember to read the instructions posted here.

    Dismiss Notice

c# problem

Discussion in 'Programming' started by sumigizlov, Nov 11, 2009.

Thread Status:
Not open for further replies.
  1. sumigizlov

    sumigizlov New Member

    Joined:
    Nov 17, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. krishnandu.sarkar

    krishnandu.sarkar Simply a DIGITian

    Joined:
    Nov 13, 2007
    Messages:
    4,693
    Likes Received:
    15
    Trophy Points:
    38
    Location:
    Kolkata
    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.....!!
     
  3. OP
    OP
    sumigizlov

    sumigizlov New Member

    Joined:
    Nov 17, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    0
    but in case of windows forms datagridview RowCommand is not available it is only available in asp.net
     
  4. vamsi360

    vamsi360 Always confused

    Joined:
    May 10, 2008
    Messages:
    348
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Garden City
    when you click the button the event is button_click.

    When you want to fire the event on page load Page_Load
     
  5. OP
    OP
    sumigizlov

    sumigizlov New Member

    Joined:
    Nov 17, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    0
    i am not asking for regular buttons i am asking for datagridview button column
     
  6. krishnandu.sarkar

    krishnandu.sarkar Simply a DIGITian

    Joined:
    Nov 13, 2007
    Messages:
    4,693
    Likes Received:
    15
    Trophy Points:
    38
    Location:
    Kolkata
    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.
     
  7. OP
    OP
    sumigizlov

    sumigizlov New Member

    Joined:
    Nov 17, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    0
    yes in asp it is rowcommand but i am asking for windows form
     
  8. lucifer_is_back

    lucifer_is_back New Member

    Joined:
    Oct 17, 2008
    Messages:
    124
    Likes Received:
    0
    Trophy Points:
    0
    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
     
    Last edited: Nov 12, 2009
  9. OP
    OP
    sumigizlov

    sumigizlov New Member

    Joined:
    Nov 17, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    0
    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
     
    Last edited: Nov 16, 2009
  10. vamsi360

    vamsi360 Always confused

    Joined:
    May 10, 2008
    Messages:
    348
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Garden City
Thread Status:
Not open for further replies.

Share This Page