473,396 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

GridView.Rows.Count & EditIndex

Hi, I've been at this one for hours and cannot not find any posts of anyone having the same problem. Ther scenario is, I need to fill a drop down box with a value in the grid row to pass to the select statement whcih returns the rows to the drop down.

Its the problem is happening in the ObjectDataSource_Selecting Event of the dropdown control when the Edit command is clicked for a grid row. I'm using the syntax , GridView.rows[EditIndex].FindControl[control with the value i need]
to get the value to pass to the object source for the drop down.

If i hit the edit link of the first row of a paged grid view, the [gridview].rows.count = 0

IF i attempt to edit the second row, the rows count is now 1, the third row, the row count is 2 and so on.

So 2 problems. If I try to get a reference to the control in the first row after the gridview goes into edit mode, I can't since the gridview.rows.count returns 0.

If I try to get a reference to controls in any other row besides the first, I get the controls in the previous row to the one I selected for editing. So If I click the edit command for row 3, and try to access a control (a bound textbox) in that row using [gridview].rows[editIndex-1] i get the value of the corresponding control from row 2.

FuIn addition, If I try to use editindex (Without the -1) i get an index out of range exception. So the grid view row count always seems to equal to the value for [gridview].editindex.

I am using a collection as a datasource.
Aug 21 '07 #1
0 4798

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John_H | last post by:
Re: ASP.NET 2.0 I would like suggestions or code examples on how to collect a variable length list of input data (item# & item quantity specifically). I thought that I could accomplish this...
4
by: Tomasz Jastrzebski | last post by:
Hello Everyone, I have a GridView control bound to a plain DataTable object. AutoGenerateEditButton is set to true, Edit button gets displayed, and RowEditing event fires as expected.
4
by: pvong | last post by:
Hi, I'm a newbie and I'm looking for some help. I'm programming in VB.Net. I have a simple gridview and when the user hits the Edit link, the gridview changes to edit mode. I replaced the...
4
by: yehey2010 | last post by:
Hi, I have problem with my ASP.Net Code, I used GridView with Edit/Update on it. However the program seems not work correctly because it doesn't Update the OLD VALUE with the NEW VALUE. Please...
0
by: ganesh22 | last post by:
Hi... Iam using GridView in asp.net(2.0) .My requirement is user can add,update,delete in gridview I written the code for add & update but can u help adding rows in grid view My code: ...
5
by: =?Utf-8?B?Z3V5?= | last post by:
How do you enable editing in a GridView programatically rather than via its Tasks menu? Guy
3
by: nguyenlh | last post by:
code: I have read a example :The use girdview without datasource <asp:GridView AutoGenerateColumns="false" ID="GridView1" runat="server" OnRowCancelingEdit="GridView1_RowCancelingEdit"...
0
by: steve | last post by:
I have been fighting with trying to update a GridView for a while. I don't want to use the "built-in" way to do it because I am using business layer methods for updating and deleteing and I don't...
3
by: sailaja71185 | last post by:
Here is my code: using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.