Solved

SelectedIndex Negative?

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

705 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

17 Experts available now in Live!

Get 1:1 Help Now