Solved

SelectedIndex Negative?

Posted on 2009-04-11
2
657 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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