Hello Stan,
DataGrid dgTemp = ((DataGrid)sender);
if(dgTemp.EditItemIndex == e.Item.ItemIndex)
{
if(e.Item.ItemType.ToString() != "Header" && e.Item.ItemType.ToString() != "Footer")
{
DropDownList ddlTemp = ((DropDownList)e.Item.FindControl("myDDL"));
ddlTemp.Items.FindByText("myLookupValue").Selected =true;
}
}
This code could probably be simplified further, but it should be a good starting point.
HTH.
Best regards,
yhhuang
VS.NET, Visual C++
Microsoft
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net?
http://www.gotdotnet.com
--------------------
!From: "Stan" <no****@yahoo.com>
!Subject: How can I access a datagrid control during Edit event?
!Date: Thu, 10 Jul 2003 11:20:22 -0400
!Lines: 25
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
!Message-ID: <#r**************@TK2MSFTNGP10.phx.gbl>
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!NNTP-Posting-Host: 12.148.36.131
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:158335
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!
!This is how I access Pieces field in my editable datargid during Update
!event:
!
!protected void grdMain_OnUpdate(Object sender, DataGridCommandEventArgs e)
!{
! string Pieces = ((TextBox) e.Item.FindControl ("txtPieces")).Text;
! ....
!}
!
!
!I need to highlight this field when user clicks Edit. (This makes easier for
!them to overwrite the content of the field). However, the same code does not
!work during
!Edit event - FindControl returns null. It looks like the the control is not
!available at this time...
!
!
!Is there a way for me to access it AFTER user clicked Edit but BEFORE
!Update?
!
!Thanks,
!
!-Stan
!
!
!