473,651 Members | 3,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_OnUpdat e(Object sender, DataGridCommand EventArgs e)
{
string Pieces = ((TextBox) e.Item.FindCont rol ("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 3951
Hello Stan,

DataGrid dgTemp = ((DataGrid)send er);
if(dgTemp.EditI temIndex == e.Item.ItemInde x)
{
if(e.Item.ItemT ype.ToString() != "Header" && e.Item.ItemType .ToString() != "Footer")
{
DropDownList ddlTemp = ((DropDownList) e.Item.FindCont rol("myDDL"));
ddlTemp.Items.F indByText("myLo okupValue").Sel ected=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.c om>
!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.publi c.dotnet.framew ork.aspnet
!NNTP-Posting-Host: 12.148.36.131
!Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
!Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1583 35
!X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
!
!This is how I access Pieces field in my editable datargid during Update
!event:
!
!protected void grdMain_OnUpdat e(Object sender, DataGridCommand EventArgs e)
!{
! string Pieces = ((TextBox) e.Item.FindCont rol ("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)send er);
if(dgTemp.EditI temIndex == e.Item.ItemInde x)
{
if(e.Item.ItemT ype.ToString() != "Header" && e.Item.ItemType .ToString() != "Footer")
{
DropDownList ddlTemp = ((DropDownList) e.Item.FindCont rol("myDDL"));
ddlTemp.Items.F indByText("myLo okupValue").Sel ected=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.c om>
!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.publi c.dotnet.framew ork.aspnet
!NNTP-Posting-Host: 12.148.36.131
!Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP10.phx.g bl
!Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1583 35
!X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
!
!This is how I access Pieces field in my editable datargid during Update
!event:
!
!protected void grdMain_OnUpdat e(Object sender, DataGridCommand EventArgs e)
!{
! string Pieces = ((TextBox) e.Item.FindCont rol ("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
4739
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 appreciated. Thanks in advance
0
1398
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 display as readonly or readwrite. The readwrite displays link buttons for edit, update, cancel and delete buttons. When I click on a edit link button the page using the usercontrol will begin it's page load event and then the usercontrol page load...
0
473
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 = "SectionTableLines"; dgG.DataKeyField = "PlanWorkOrderID";
2
3745
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 <asp:EditCommandColumn> I want either a textbox or dropdown to appear when I check what is being edited. I thought I could create the dropdown on the fly and add it to the datagrid as below but It's not appearing. I imagined I could populate the dropdown
1
4227
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 the example to work. I created the following two classes, provided with the example: *-*-**-*-*-*-*-*-*-*-*-*-**-*-*-*-*-CheckBoxColumn Class:-*-*-*-*-*-*-*-*-*-*-**-*-*-*-*-**-*-*-*
4
3936
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 out at this point. What I have is this : Members.aspx file:
3
1403
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 ASPX page loads in the browser. Now since the DataGrid has got its OnItemCreated event, will it's event function i.e. "InEditMode()" execute before the Page_Load sub executes or will it execute after the Page_Load sub gets executed? Thanks,
9
2713
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 code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (Page.IsPostBack) Then FillDataGrid()
1
1509
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 round-trips and at the time data is bound to the control. Can someone please explain what does the above line mean preferably with examples?
0
8361
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8278
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8807
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8701
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8466
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8584
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5615
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2701
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.