Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Assimalyst #1
Cant reference cell text
Hi,
I'm attempting an update SQl Server using a gatagrid using ADO.
I am having trouble getting a changed value to work however.
The datagrid is populated as below:
sampleNo brush biopsy lavage histology patinetNo
Edit 87 True True True Squamous 67
The only editable column is histology.
I am using the following code to try to update any changes to that
cell:
DataRow sRow = dsSample.Tables["Table"].Rows[0];
sRow["Histology"] = ((TextBox)e.Item.Cells[5].Controls[0];
But no update occurs. If i change it to:
DataRow sRow = dsSample.Tables["Table"].Rows[0];
sRow["Histology"] = "New Text";
Then it does update. So it seems my cell referencing is wrong. Can
anyone tell me why? I have tried changing the [5] and [0], but get
errors.
Thanks.
Assimalyst Guest
-
Moving text into the next cell
I am working on a large project with a lot of tables. The raw copy/lists come from Word and are in general set up with tabs, which makes it an easy... -
Cell Rendering / Change Text
I have a data grid that is using cellrendering in on of the columns to provide a check box. When I check the box I would like to be able to change... -
wrapping text in a datagrid cell
I have a datagrid that I am having text wrapping problems with. And the wrapping problems only happen with text containing long urls. If I set... -
Can't reference a datagrid cell
Hi All, I'm developing a set of custom controls for a trouble ticket website. I have a class that handles accessing the database for calls such... -
Win32-OLE excel cell reference.
Guys, I'm struggling with the syntax to point to the cells that I want to use in Excel. It seems that the Range command likes data like (A14),... -
Brock Allen #2
Re: Cant reference cell text
Put a breakpoint in the debugger to see how many child controls are under
the Cell -- there may be more than one if it's a template column.
-Brock
DevelopMentor
[url]http://staff.develop.com/ballen[/url]
> Hi,
>
> I'm attempting an update SQl Server using a gatagrid using ADO.
>
> I am having trouble getting a changed value to work however.
>
> The datagrid is populated as below:
>
> sampleNo brush biopsy lavage histology patinetNo
> Edit 87 True True True Squamous 67
>
> The only editable column is histology.
>
> I am using the following code to try to update any changes to that
> cell:
>
> DataRow sRow = dsSample.Tables["Table"].Rows[0];
> sRow["Histology"] = ((TextBox)e.Item.Cells[5].Controls[0];
> But no update occurs. If i change it to:
>
> DataRow sRow = dsSample.Tables["Table"].Rows[0];
> sRow["Histology"] = "New Text";
> Then it does update. So it seems my cell referencing is wrong. Can
> anyone tell me why? I have tried changing the [5] and [0], but get
> errors.
>
> Thanks.
>
Brock Allen Guest
-
Assimalyst #3
Re: Cant reference cell text
Thanks for the suggestion Brock.
I've put a breakpoint in the debugger, i then expanded 'e' then 'Item'
and found there are listings for 'Cells' and 'cells', i've expanded
these and the 'owner', then get an option again of expanding 'Cells'
and 'cells' (amongst others), and it seems i can continue expanding
'Cells' then 'owner' for quite some time . . .
Not really sure what i'm looking for from here. Could you point me in
the right direction please?
Thanks again.
Assimalyst Guest
-
Elton Wang #4
Re: Cant reference cell text
You can't assign a control, TextBox, to ["Histology"]. You should use a
string value to update sRow["Histology"] like :
TextBox txtHistology = ((TextBox)e.Item.Cells[5].Controls[0];
sRow["Histology"] = txtHistology.Text;
HTH
"Assimalyst" <c_oxtoby@hotmail.com> wrote in message
news:1125928775.560050.307660@g44g2000cwa.googlegr oups.com...> Hi,
>
> I'm attempting an update SQl Server using a gatagrid using ADO.
>
> I am having trouble getting a changed value to work however.
>
> The datagrid is populated as below:
>
> sampleNo brush biopsy lavage histology patinetNo
> Edit 87 True True True Squamous 67
>
> The only editable column is histology.
>
> I am using the following code to try to update any changes to that
> cell:
>
> DataRow sRow = dsSample.Tables["Table"].Rows[0];
> sRow["Histology"] = ((TextBox)e.Item.Cells[5].Controls[0];
>
> But no update occurs. If i change it to:
>
> DataRow sRow = dsSample.Tables["Table"].Rows[0];
> sRow["Histology"] = "New Text";
>
> Then it does update. So it seems my cell referencing is wrong. Can
> anyone tell me why? I have tried changing the [5] and [0], but get
> errors.
>
> Thanks.
>
Elton Wang Guest
-
Assimalyst #5
Re: Cant reference cell text
Thanks Elton,
Tried that, but still getting the same behaviour as above. The database
is not updating.
I can only presume something is wrong with the
((TextBox)e.Item.Cells[5].Controls[0]) statement. But what??
Thanks again.
Assimalyst Guest
-
Elton Wang #6
Re: Cant reference cell text
One most likely reason is that data in the textbox is overwritten by data
from database. You might rebind the datagrid's data source before performing
update function. Normally, we should bind the datagrid's data source when
IsPostback = false.
HTH
"Assimalyst" <c_oxtoby@hotmail.com> wrote in message
news:1126014179.140686.153930@g14g2000cwa.googlegr oups.com...> Thanks Elton,
>
> Tried that, but still getting the same behaviour as above. The database
> is not updating.
>
> I can only presume something is wrong with the
> ((TextBox)e.Item.Cells[5].Controls[0]) statement. But what??
>
> Thanks again.
>
Elton Wang Guest



Reply With Quote

