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

Find the value of a read only datagrid cell

Help..

I have been using:
string sId =
((System.Web.UI.WebControls.TextBox)e.Item.Cells[2].Controls[0]).Text;
To get the value of a cell in my datagrid.

When I set the cell to read only, I get an error message.

I need to retrieve this value so I can use it in my query to update the
database.

Thanks for any help.

Jeff
Nov 29 '05 #1
3 2113
When it's readonly, I would imagine there is no textbox in the cell. But you
are expecting one.

"Jeff" <Je**@discussions.microsoft.com> wrote in message
news:19**********************************@microsof t.com...
Help..

I have been using:
string sId =
((System.Web.UI.WebControls.TextBox)e.Item.Cells[2].Controls[0]).Text;
To get the value of a cell in my datagrid.

When I set the cell to read only, I get an error message.

I need to retrieve this value so I can use it in my query to update the
database.

Thanks for any help.

Jeff

Nov 29 '05 #2
Is it read-only or disabled? If it is read-only you can read it on the server
side. Step through the code using the debugger to see if you are picking up
the right control. It is usually easier to give the control an ID, use
FindControl, check if the returned value is not null then take its value
(instead of doing all of them in one code line that throws an exception if
the control was not found where you thought it was)

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Jeff" wrote:
Help..

I have been using:
string sId =
((System.Web.UI.WebControls.TextBox)e.Item.Cells[2].Controls[0]).Text;
To get the value of a cell in my datagrid.

When I set the cell to read only, I get an error message.

I need to retrieve this value so I can use it in my query to update the
database.

Thanks for any help.

Jeff

Nov 29 '05 #3
What I said applies if the object is a read-only textbox (as it appeared to
me from your code where you cast the object to a TextBox). But if you were
attempting to retrieve the value in a cell that resulted from a BoundColumn
whose ReadOnly was set to "true" then you certainly will get an error because
a BoundColumn renders text within a TD tag (no input objects within the
rendered TD tag).

If you wanted to retrieve the values in a cell whose value you manipulated
on the client-side you would have to use HTMLInputHidden objects as I did in
this sample: http://www.societopia.net/samples/dataGrid_3.aspx

But if you were trying to retrieve the original value on datagrid cell then
you can do that from the underlying datasource.

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Phillip Williams" wrote:
Is it read-only or disabled? If it is read-only you can read it on the server
side. Step through the code using the debugger to see if you are picking up
the right control. It is usually easier to give the control an ID, use
FindControl, check if the returned value is not null then take its value
(instead of doing all of them in one code line that throws an exception if
the control was not found where you thought it was)

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Jeff" wrote:
Help..

I have been using:
string sId =
((System.Web.UI.WebControls.TextBox)e.Item.Cells[2].Controls[0]).Text;
To get the value of a cell in my datagrid.

When I set the cell to read only, I get an error message.

I need to retrieve this value so I can use it in my query to update the
database.

Thanks for any help.

Jeff

Nov 29 '05 #4

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

Similar topics

3
by: Dav | last post by:
I have a Winform with a derived datagrid and a button that adds a row to the datagrid in its Click event. The button has a shortcut text "&New Row". When I enter a value in a datagrid cell and...
2
by: kscdavefl | last post by:
I have a column on a web page datagrid that contains a value. I want to take the value and populate another cell on the grid. If the value in cell number 6 is 0 I want to make the value in cell 1...
1
by: Blake Versiga | last post by:
When editing a datagrid (C#) I need to know if the user changed the value of cell AND what the previous value was. Is this possible? If so how do I get the previous value or at least if the...
2
by: Michael | last post by:
Need some help trying to read values from web controls - specifically *finding* the controls (like a drop down list) - that are added dynamically added within an asp:panel control. The page...
9
by: Paul | last post by:
Hi I have a data grid with a hyperlink column. the colum has numbers like 00001,000002, ect. Just wondering how to get the text value of the cell as tempstring =...
4
by: gugu | last post by:
Hi I have a datagrid which has 20 rows and 20 columns, 15 of 20 columns are checkboxs and their headertexts, datafields are dynamic. I need to loop through the whole page to see if the specific...
4
by: Aaron Smith | last post by:
Dim dv As DataView = New DataView(FacilitiesDS1.Facilities, "", "ID ASC", DataViewRowState.CurrentRows) Dim iPos As Integer = dv.Find(dr.Item("ID")) Me.BindingContext(FacilitiesDS1,...
4
by: Roger | last post by:
I have a datagrid and would like to know what even fires when a cell is changed? I want to know when the user changes a cell and moves to the next. I have some code that needs to be done to...
0
by: Matt | last post by:
I derived my own custom class from the datagrid class. I overrode the ProcessCmdKey Function, like this, to catch the up and down arrow keys: ====== Protected Overrides Function...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.