Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SelectedIndex Negative?

Posted on 2009-04-11
2
Medium Priority
?
695 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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 video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

916 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