Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspdotnet_website_programming thread: ASP.NET DataGRID problem.


Message #1 by "Barry Young" <youngbar@i...> on Sun, 14 Apr 2002 19:11:52 -0500
This is a multi-part message in MIME format.

------=_NextPart_000_000D_01C1E3E8.3C02AA50
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Assumptions:

Databinding is working correctly, and the grid is displaying properly 
with the data in it.  When you click <Edit>, the EditItem Template 
displays the text box with the data in it.  I change the data in the 
text box for LastName and click <Update>.

When I look at the value in
 CType(e.Item.FindControl("txtLastName"), TextBox).Text

It is NOT giving me the current value of the CHANGED data in the 
txtLastName text box.  It still has the OLD value in it.


HERE IS THE CODE:



Public Sub DataGrid1_Update(ByVal sender As Object, ByVal e As 
DataGridCommandEventArgs)

        Dim strLastName As String =3D  
CType(e.Item.FindControl("txtLastName"), TextBox).Text



    End Sub


    Sub DataGrid1_Edit(ByVal Sender As Object, ByVal E As 
DataGridCommandEventArgs)

        DataGrid1.EditItemIndex =3D CInt(E.Item.ItemIndex)

        DataGrid1.DataBind()

    End Sub


<asp:datagrid id=3D"DataGrid1" style=3D"Z-INDEX: 101; LEFT: 8px; 
POSITION: absolute; TOP: 214px" runat=3D"server" 
OnEditCommand=3D"DataGrid1_Edit" OnUpdateCommand=3D"DataGrid1_Update" 
ItemStyle-Font-Size=3D"10" ItemStyle-Font-Name=3D"arial" 
AlternatingItemStyle-BackColor=3D"#ffffcc" 
HeaderStyle-ForeColor=3D"#ffffff" HeaderStyle-Font-Size=3D"11" 
HeaderStyle-Font-Bold=3D"True" HeaderStyle-Font-Name=3D"arial" 
HeaderStyle-BackColor=3D"#ff0000" CellPadding=3D"3" 
BorderColor=3D"Black" BackColor=3D"White" Width=3D"500px" 
Height=3D"25px">
<AlternatingItemStyle ForeColor=3D"#FFFF33" Width=3D"75px" 
BackColor=3D"#006699"></AlternatingItemStyle>
<ItemStyle Font-Size=3D"12pt" Font-Names=3D"arial" Height=3D"25px" 
ForeColor=3D"White" Width=3D"70px" BackColor=3D"#336666"></ItemStyle>
<HeaderStyle Font-Size=3D"11pt" Font-Names=3D"arial" Font-Bold=3D"True" 
ForeColor=3D"White" BackColor=3D"RoyalBlue"></HeaderStyle>
<Columns>

<asp:EditCommandColumn ButtonType=3D"LinkButton" UpdateText=3D"Update" 
HeaderText=3D"Function" CancelText=3D"Cancel" 
EditText=3D"Edit"></asp:EditCommandColumn>

<asp:TemplateColumn SortExpression=3D"LastName" HeaderText=3D"LastName">
<ItemTemplate>
<asp:Label style=3D "Position: Center" runat=3D"server" 
id=3D"lblLastName" width =3D "75px" 
text=3D'<%#DataBinder.Eval(Container.DataItem, "LastName") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat=3D"server" id=3D"txtLastName" width =3D "75px" 
text=3D'<%#DataBinder.Eval(Container.DataItem, LastName%>'/>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>




  Return to Index