Datagrid Cells: Getting the value

  • Thread starter Thread starter ALPO
  • Start date Start date
A

ALPO

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?
 
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?
 
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.
 
Back
Top