Solved

SelectedIndex Negative?

Posted on 2009-04-11
2
612 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

867 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

22 Experts available now in Live!

Get 1:1 Help Now