Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem with setting a gridview's SelectedIndex property in code

Reply
Thread Tools

Problem with setting a gridview's SelectedIndex property in code

 
 
=?Utf-8?B?RnJvZWZlbA==?=
Guest
Posts: n/a
 
      07-25-2007
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with setting a gridview's SelectedIndex property in code Froefel ASP .Net 0 07-25-2007 01:32 PM
Problem with setting a gridview's SelectedIndex property in code Froefel ASP .Net 0 07-25-2007 12:07 PM
Problem with setting a gridview's SelectedIndex property in code Froefel ASP .Net 0 07-24-2007 05:34 PM
Strange problem with SelectedIndex property affecting multiple dropdownlists RSH ASP .Net 3 02-08-2007 07:13 PM
Problem with HTMLSelect.SelectedIndex and client disabled property Harry Keck ASP .Net Web Controls 0 01-27-2005 03:19 PM



Advertisments