473,382 Members | 1,745 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,382 software developers and data experts.

DataGrid Edit Problem - No value access?

Hi,

I'm unable to access values in my Datagrid. Datagrid thinks it hase only 1
Cell. So here it is:

The Datagrid is binded in PageLoad, AutoGenerateColumns is false, Columns
are added on PageLoad like this:
BoundColumn Bound_Column = new BoundColumn();

Bound_Column.DataField = name; ( + HeaderText,
SortExpression, Visible)
DataGrid1.Columns.Add(Bound_Column);

DataGrid has all values. Then user edits one Row and clicks on 'Update'.
Eventhandler for Update is called. Now here is my real problem, i could not
access any row. Datagrid tells me that it as 15 Items (Page), but only 1
Cell (Edit Cell i think). I tried to access datarow via:

for (int i = 1; i < 15; i++) // We have 15 Rows... E. g. (as
e.Utem.Cells.Count is 1)

String columnContent = ((TextBox)e.Item.Cells[i].Controls[0]).Text;

This leads to an Out of Range Exceptions, as Datagrid has only How can i
access the value of the current row?

Thanks for your help,

_MC_
Apr 3 '07 #1
4 2096
bpd
On Apr 3, 1:39 pm, "_MC_" <mc@localhostwrote:
Hi,

I'm unable to access values in my Datagrid. Datagrid thinks it hase only 1
Cell. So here it is:

The Datagrid is binded in PageLoad, AutoGenerateColumns is false, Columns
are added on PageLoad like this:
BoundColumn Bound_Column = new BoundColumn();

Bound_Column.DataField = name; ( + HeaderText,
SortExpression, Visible)

DataGrid1.Columns.Add(Bound_Column);

DataGrid has all values. Then user edits one Row and clicks on 'Update'.
Eventhandler for Update is called. Now here is my real problem, i could not
access any row. Datagrid tells me that it as 15 Items (Page), but only 1
Cell (Edit Cell i think). I tried to access datarow via:

for (int i = 1; i < 15; i++) // We have 15 Rows... E. g. (as
e.Utem.Cells.Count is 1)

String columnContent = ((TextBox)e.Item.Cells[i].Controls[0]).Text;

This leads to an Out of Range Exceptions, as Datagrid has only How can i
access the value of the current row?

Thanks for your help,

_MC_
Are your cells editable (i.e. not set to ReadOnly)?

Apr 3 '07 #2
On Apr 3, 10:39 am, "_MC_" <mc@localhostwrote:
Hi,

I'm unable to access values in my Datagrid. Datagrid thinks it hase only 1
Cell. So here it is:

The Datagrid is binded in PageLoad, AutoGenerateColumns is false, Columns
are added on PageLoad like this:
BoundColumn Bound_Column = new BoundColumn();

Bound_Column.DataField = name; ( + HeaderText,
SortExpression, Visible)

DataGrid1.Columns.Add(Bound_Column);

DataGrid has all values. Then user edits one Row and clicks on 'Update'.
Eventhandler for Update is called. Now here is my real problem, i could not
access any row. Datagrid tells me that it as 15 Items (Page), but only 1
Cell (Edit Cell i think). I tried to access datarow via:

for (int i = 1; i < 15; i++) // We have 15 Rows... E. g. (as
e.Utem.Cells.Count is 1)

String columnContent = ((TextBox)e.Item.Cells[i].Controls[0]).Text;

This leads to an Out of Range Exceptions, as Datagrid has only How can i
access the value of the current row?

Thanks for your help,

_MC_
are you using a master page?
if so are you giving your master page an id?

i had a similar problem where i was losing the values of datakeys
within a gridview (on top of another weird treeview error)
and after many attempts at fixing it, i don't know why but i removed
the id i was assigning the master page and it worked. i placed the id
once again just to make sure and had the same error.
don't know what's causing it really but at least that solved my
problems

hope it helps

Apr 3 '07 #3
Hi,

bdp: "Are your cells editable (i.e. not set to ReadOnly)?"

they are all editable. Even if they are not editable I should have
access on it, or?
chanko: we're currently using an master page, but what do you mean with
"if so are you giving your master page an id?"?
Thanks,
_MC_
Apr 3 '07 #4
Hi,

some debug hours later...

User Html Code only contains javascript postback for Cell 0 (the static edit
Cell) on edit command, so we never get any information about the user
changed.

http://msdn2.microsoft.com/en-us/library/aa478966.aspx wrote:

"If you do find yourself in one of these scenarios, be aware that your
dynamic controls do not preserve themselves when the page is submitted."

That seems to be my problem, nevertheless there must be a chance to access
the changed values, musn't it? We only need those values, if datagrid does
not preserve values is irrelevant. We simple had to access those values.
It's no possible that all other column values are lost.

Note: If i manually add the columns in designer mode all here created
columns are present on update. However, we need to create the columns on
runtime as we have e. g. an drop down menue for table, etc so it's not
possible in my eyes to to this static.
Thanks for your help!
_MC_
"_MC_" <mc@localhostschrieb im Newsbeitrag
news:eh****************@TK2MSFTNGP05.phx.gbl...
Hi,

bdp: "Are your cells editable (i.e. not set to ReadOnly)?"

they are all editable. Even if they are not editable I should have access
on it, or?
chanko: we're currently using an master page, but what do you mean with
"if so are you giving your master page an id?"?
Thanks,
_MC_

Apr 4 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: San Diego Guy | last post by:
Hi all! I have Datagrid. Within that datagrid I have a drop down list that I set up some values in (a "collection") I set up an edit command column on the datagrid and wrote simple code to get...
1
by: Maziar Aflatoun | last post by:
Hi everyone, Here is my problem. I have a datagrid that I binds to a table with the following fields. PID FirstName LastName In my datagrid I display FirstName and LastName along with a...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
1
by: Harry Devine | last post by:
I have a DataGrid that is configured to use the Edit/Update/Cancel concept correctly. My grid shows values from 5 database fields. I only need to update that last 4 fields. The last field is a...
1
by: Anna | last post by:
I have a simple DataGrid that displays a list of characteristics and allows you to edit a description for each characteristic. The query that feeds this involves a join, as the characteristics and...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
6
by: Ron L | last post by:
I have a dataset whose source is a SQL 2k stored procedure that I am trying to display in a datagrid. This datasource has 4 columns that I am interested in here, a text column and 3 value columns...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.