Thursday, March 29, 2012

OnTextChanged and DataGridItems

Hi,
I currently have a datagrid with template columns containing textboxes etc.
The textboxes are in the item template so the whole grid is editable by
default, I then have a general update button to update the whole grid. I'm
using the example under
http://msdn.microsoft.com/library/d...>
erControl.asp
I'm using the OnTextChanged event to capture which rows have been changed by
the user. Inside of this event I want to update the datasource of the
datagrid with the new values, my problem is that I can't seem to access the
new values. At this point everything is empty. I'm using
DataGridItem.Cells[0].Text etc to get the values, I can see that the grid ha
s
the correct number of cells using the count but the values are all ""... any
ideas?because your using a textbox event and not a datagrid event you dont
now from which row to get the new data?
you could try accessing the value from sender withing the textbox event
ctype(sender, textbox).text
but now you will need to know which row to save it into?
personally i wouldnt use OnTextChanged to save because it will cause
alot of server overhead.
coz it will do a server postback on each keypress wont it?
examnotes wrote:
> Hi,
> I currently have a datagrid with template columns containing
textboxes etc.
> The textboxes are in the item template so the whole grid is editable
by
> default, I then have a general update button to update the whole
grid. I'm
> using the example under
>
http://msdn.microsoft.com/library/d...rverControl.asp
> I'm using the OnTextChanged event to capture which rows have been
changed by
> the user. Inside of this event I want to update the datasource of the

> datagrid with the new values, my problem is that I can't seem to
access the
> new values. At this point everything is empty. I'm using
> DataGridItem.Cells[0].Text etc to get the values, I can see that the
grid has
> the correct number of cells using the count but the values are all
""... any
> ideas?
Oops! Made a silly mistake, I've fixed this now.
I need to look at the controls collection within the cells to access the
textboxes!
thanks
"Neil" wrote:

> Hi,
> I currently have a datagrid with template columns containing textboxes etc
.
> The textboxes are in the item template so the whole grid is editable by
> default, I then have a general update button to update the whole grid. I'm
> using the example under
> http://msdn.microsoft.com/library/d...>
erControl.asp
> I'm using the OnTextChanged event to capture which rows have been changed
by
> the user. Inside of this event I want to update the datasource of the
> datagrid with the new values, my problem is that I can't seem to access th
e
> new values. At this point everything is empty. I'm using
> DataGridItem.Cells[0].Text etc to get the values, I can see that the grid
has
> the correct number of cells using the count but the values are all ""... a
ny
> ideas?

0 comments:

Post a Comment