Problem with setting a gridview's SelectedIndex property in code
I have a gridview "gdCustomers" with several columns. Column is a
LinkButton with CommandName="Select" and column is a ButtonField
with ButtonType="Image" and CommandName="EditNotes".
When I click a link in column, the corresponding gridrow is
selected, as it should.
When I click the image in column, I intercept the
gdCustomers_RowCommand() event and execute the following logic:
protected void gdCustomers_RowCommand(object sender,
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.
|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.