473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How can I access a datagrid control during Edit event?

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
Nov 17 '05 #1
2 3941
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
!
!
!
Nov 17 '05 #2
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
!
!
!
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
0
by: Daniel Armstrong | last post by:
Hello, I have a usercontrol that I have built that has a single generic datagrid. When setting up the inital properties I build the template columns for the datagrid dynamically so it can...
0
by: Steve | last post by:
I have a datagrid that is created at run time DataGrid dgG = new DataGrid(); BoundColumn bcB; dgG.CellPadding = 5; dgG.CellSpacing = 0; dgG.GridLines = GridLines.Both; dgG.CssClass =...
2
by: Dave | last post by:
Hi, I'm building a maintenance form for a table and some of the fields are textboxes (i.e name) and some should be dropdowns (i.e country of origin) When a user clicks 'Edit' in the...
1
by: sianan | last post by:
I tried to use the following example, to add a checkbox column to a DataGrid in an ASP.NET application: http://www.codeproject.com/aspnet/datagridcheckbox.asp For some reason, I simply CAN'T get...
4
by: Frank | last post by:
Hello All, I ham using VS.NET 2003. Have followed instructions from http://gridviewguy.com/ArticleDetails.aspx?articleID=26 along with several other articles to no avail. I am pulling my hair...
3
by: Arpan | last post by:
A DataGrid displays data from a DataSet. The DataGrid has the OnItemCreated event. Assume that the OnItemCreated event calls a sub named "InEditMode()". The DataGrid gets rendered as soon as this...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
1
by: rn5a | last post by:
In the .NET2.0 SDK Documentation, the DataGrid's OnItemCreated method is described as thus: The ItemCreated event is raised when an item in the DataGrid control is created, both during...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.