469,609 Members | 1,626 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Datagrid Cells: Getting the value

We have a datagrid built using template columns. Many are
text boxes. These text boxes are bound to a datasource as
follows: <ItemTemplate>
<asp:TextBox
id="txtPeriod1"
runat="server"
columns="1"
Font-Size="8pt"
text='<%# Container.dataitem
("LaborHoursAm")%>' >
</asp:TextBox>
</ItemTemplate>

My problem arises when I change the data (like changing
txtPeriod1 from 80 to 30) in the column and try to
retrieve it. When I spin through the datagrid values I see
the "80", the bound value, not the "30" the value I want
to change it too. Is there a way I can accomplish this?
Nov 18 '05 #1
3 1458
If you are using a DataSet - - you need to first, update the dataset before
you 'spin through' the datagrid (I assume you mean Dataset - - otherwise - -
show us how you're doing it)
David Wier
MCP, MVP ASP.NET, ASPInsider
http://aspnet101.com
http://aspexpress.com
"ALPO" <an*******@discussions.microsoft.com> wrote in message
news:06****************************@phx.gbl...
We have a datagrid built using template columns. Many are
text boxes. These text boxes are bound to a datasource as
follows: <ItemTemplate>
<asp:TextBox
id="txtPeriod1"
runat="server"
columns="1"
Font-Size="8pt"
text='<%# Container.dataitem
("LaborHoursAm")%>' >
</asp:TextBox>
</ItemTemplate>

My problem arises when I change the data (like changing
txtPeriod1 from 80 to 30) in the column and try to
retrieve it. When I spin through the datagrid values I see
the "80", the bound value, not the "30" the value I want
to change it too. Is there a way I can accomplish this?

Nov 18 '05 #2
Yes it is a dataset. However, how can i update the
dataset with the new value? The tricky part is we are
trying to avoid the single row edits so we don't have
an "editcommandbutton". Our thought was to spin through
the items in the datagrid page, update the dataset, then
bind the grid again. Here is what i am trying to do in
the code behind.

For iItemCount = 0 To LaborGrid.Items.Count - 1
LaborGrid.SelectedIndex = iItemCount
Debug.Write(LaborGrid.SelectedIndex & vbCrLf)
With LaborGrid.SelectedItem
Debug.Write("selecteditem :" &
LaborGrid.SelectedItem.Cells(8).Text & vbCrLf)
txtbox = LaborGrid.SelectedItem.FindControl
("txtPeriod1")
'value = txtbox.Text
'Debug.Write("value :" & value & vbCrLf)
End With
Next

I get my selecteditem number ok, but I can't get the new
number. I am missing something here, something that
the "editcommandbutton" would do. We are using a non-grid
button because the user wants to be able to update any
column of any row before updating. Is it possible?
-----Original Message-----
If you are using a DataSet - - you need to first, update the dataset beforeyou 'spin through' the datagrid (I assume you mean Dataset - - otherwise - -show us how you're doing it)
David Wier
MCP, MVP ASP.NET, ASPInsider
http://aspnet101.com
http://aspexpress.com
"ALPO" <an*******@discussions.microsoft.com> wrote in messagenews:06****************************@phx.gbl...
We have a datagrid built using template columns. Many are text boxes. These text boxes are bound to a datasource as follows: <ItemTemplate>
<asp:TextBox
id="txtPeriod1"
runat="server"
columns="1"
Font-Size="8pt"
text='<%# Container.dataitem
("LaborHoursAm")%>' >
</asp:TextBox>
</ItemTemplate>

My problem arises when I change the data (like changing
txtPeriod1 from 80 to 30) in the column and try to
retrieve it. When I spin through the datagrid values I see the "80", the bound value, not the "30" the value I want
to change it too. Is there a way I can accomplish this?

.

Nov 18 '05 #3
This is basically what i want to do......

1) The user changes values for a few columns in different
rows
2)The user clicks a "recalc" button
3)The new values of the cells in are updated into the
cached dataset
4)Perform a DataBind

Sorry if I am confusing you, I've just been trying to skin
this cat for a couple of days, and I am furstrated and
beginning to think it can't be done.
-----Original Message-----
If you are using a DataSet - - you need to first, update the dataset beforeyou 'spin through' the datagrid (I assume you mean Dataset - - otherwise - -show us how you're doing it)
David Wier
MCP, MVP ASP.NET, ASPInsider
http://aspnet101.com
http://aspexpress.com
"ALPO" <an*******@discussions.microsoft.com> wrote in messagenews:06****************************@phx.gbl...
We have a datagrid built using template columns. Many are text boxes. These text boxes are bound to a datasource as follows: <ItemTemplate>
<asp:TextBox
id="txtPeriod1"
runat="server"
columns="1"
Font-Size="8pt"
text='<%# Container.dataitem
("LaborHoursAm")%>' >
</asp:TextBox>
</ItemTemplate>

My problem arises when I change the data (like changing
txtPeriod1 from 80 to 30) in the column and try to
retrieve it. When I spin through the datagrid values I see the "80", the bound value, not the "30" the value I want
to change it too. Is there a way I can accomplish this?

.

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by kscdavefl | last post: by
6 posts views Thread by p.mc | last post: by
9 posts views Thread by rn5a | last post: by
reply views Thread by rn5a | last post: by
reply views Thread by Solution2021 | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.