Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding the record information in the GridView
Message
 
 
To
18/03/2008 08:18:09
General information
Forum:
ASP.NET
Category:
Other
Environment versions
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01302710
Message ID:
01303476
Views:
13
When I was reading help on DataControlRowType at http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.datacontrolrowtype.aspx

I found a sample in RowCreated method that may have helped me to use the original code as is. Anyway, since I got it working different way (using hidden field, may be very ineffecient solution) I'll leave it as is for now.

Here it is for the future reference:
void CustomersGridView_RowCreated(Object sender, GridViewRowEventArgs e)
  {

    // The GridViewCommandEventArgs class does not contain a
    // property that indicates which row's command button was
    // clicked. To identify which row was clicked, use the button's
    // CommandArgument property by setting it to the row's index.
    if(e.Row.RowType == DataControlRowType.DataRow)
    {
      // Retrieve the LinkButton control from the first column.
      LinkButton addButton = (LinkButton)e.Row.Cells[0].Controls[0];

      // Set the LinkButton's CommandArgument property with the
      // row's index.
      addButton.CommandArgument = e.Row.RowIndex.ToString();
    }

  }
BTW, to show some of my other frustrations with IDE - in VFP it's enough to highlight some command and press F1 to get help. In VS I'm getting completely unrelated help doing this and have to always google for help - very inconvenient :(

>Hi Naomi
>
>I' not sure what you are trying to do there.
>
>if SelectedIndex is -1 then nothing is selected in the grid.
>
>You need to select something or set SelectedIndex to something.
>
>
>Nick
>
>
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform