473,327 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

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

Jul 24 '07 #1
0 1800

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: charliewest | last post by:
Using .Net CF, i have created a 2 dimension ArrayList, and "binded" this list to a ComboBox control using the "DataSource" property. I have set the DisplaySource and ValueMember properties as well....
4
by: camainc | last post by:
I am adding some objects to a standard list box. When I add multiple objects, I experience no problems. However, when I add a single object, I cannot set the SelectedIndex property to 0 - it stays...
0
by: reddog | last post by:
Getting the SelectedIndex of a DropDownlist under the ItemTemplate in a GridView is harder than I thought it would be. I have: A Gridview of n rows bound to a DataSet. A DropDownList as an...
8
by: AG | last post by:
ASP.NET 2.0, VS 2005 I have a gridview with paging enabled, bound to an objectdatasource. Both were dropped on to the page and configured via the wizards. Basically working as expected. The...
0
by: Q. John Chen | last post by:
I have a GridView and a FormView serve as master/detail relation. The GridView has paging enabled - 10 rows/page. The formView is linked to gridView's SelectedValue as the sole parameter. ...
7
by: aljamala | last post by:
Hi, I was wondering if there is a way to make a single cell readonly within a GridView? I know you can do it for a column but what about a cell within that column? Thanks!
3
by: RSH | last post by:
Hi, I am having this very bizarre occurance with 4 dropdown lists on my ASP .Net page. Each control has its own unique id. When the user selects a value from each of the dropdownlists it is...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
0
by: Froefel | last post by:
Hi group, 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"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.