Solved

SelectedIndex Negative?

Posted on 2009-04-11
2
623 Views
Last Modified: 2012-05-06
Hello,

I've got a bound GridView with a checkbox template field next to a disabled "quantity" textbox.  I want to enable the textbox when I click on the checkbox.  For now, I'm setting "Autopostback" to true on the checkbox.  When I try to get the selected index row of the grid to ensble the appropriate textbox, the value is -1.  

The checkbox is mapped in the selectedIndexChanged event of the grid, andit goes there, but I don't have a row value.  Why is this?
0
Comment
Question by:NigelRocks
2 Comments
 
LVL 5

Expert Comment

by:mrcoolcoder
ID: 24122704
Are you rebinding the Grid on every postback because the selectedIndex is only available after GrridView_DataBound event is fired.?
0
 
LVL 3

Accepted Solution

by:
rbradberry earned 500 total points
ID: 24130916
in the page load you need to wrap the GridView.Datbind() event in If Not Page.IsPostBack

ie:

If Not Page.IsPostBack Then
    GridView1.Datasource = blah
    Gridview1.DataBind()
End If
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now