Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Find the value of a read only datagrid cell

Reply
Thread Tools

Find the value of a read only datagrid cell

 
 
=?Utf-8?B?SmVmZg==?=
Guest
Posts: n/a
 
      11-29-2005
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
 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      11-29-2005
When it's readonly, I would imagine there is no textbox in the cell. But you
are expecting one.

"Jeff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      11-29-2005
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

 
Reply With Quote
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      11-29-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP1 DataGrid Cannot Update /Read entered cell value. =?Utf-8?B?bWlrZWc=?= ASP .Net 0 06-25-2007 11:54 PM
Database file and folder are not read only but error message says it is read only?? keithb ASP .Net 2 06-07-2006 03:40 PM
How to set cell background based on cell value when datagrid is displayed RJ ASP .Net Datagrid Control 1 02-17-2005 09:37 PM
RadioButtonList In A DataGrid Cell - Can I find the selected button without editing the cell? Empire City ASP .Net Datagrid Control 3 04-30-2004 12:19 AM
find value of cell in datagrid? Don Hans ASP .Net Web Controls 3 12-19-2003 10:07 PM



Advertisments