Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Problem with setting a gridview's SelectedIndex property in code (http://www.velocityreviews.com/forums/t524668-problem-with-setting-a-gridviews-selectedindex-property-in-code.html)

Froefel 07-25-2007 01:32 PM

Problem with setting a gridview's SelectedIndex property in code
 
Hi group,

I have a gridview "gdCustomers" with several columns. Column[0] is a
LinkButton with CommandName="Select" and column[1] is a ButtonField
with ButtonType="Image" and CommandName="EditNotes".

When I click a link in column[0], the corresponding gridrow is
selected, as it should.
When I click the image in column[1], I intercept the
gdCustomers_RowCommand() event and execute the following logic:
protected void gdCustomers_RowCommand(object sender,
GridViewCommandEventArgs e)
{
if (e.CommandName == "EditNotes")
{
int index = Convert.ToInt32(e.CommandArgument);
gdCustomers.SelectedIndex = index;

//execute some more stuff here;
}
}

However, even though I explicitly set the row whose image was clicked
to be selected, when the page gets returned to the browser, the row is
not visible selected (it doesn't have the SelectedRow style). Now,
when I click the image a second time, the row gets visibly selected.

Could anyone tell me what I'm doing wrong and why I need to click the
image twice to get the selection to display. Note that the code itself
does get executes the first time I click the image.

Any help would be greatly appreciated.

-- Hans



All times are GMT. The time now is 05:59 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.