473,782 Members | 2,554 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

accessing control in EmptyDataTempla te

hi

asp.net 2.0

I have a GridView here with some controls in it's EmptyDataTempla te. I'm
wondering how I can get access to those controls. I've tryed using
FindControl, but that doesn't work because EmptyDataTempla te doesn't have
that method

<EmptyDataTempl ate>
<asp:TextBox ID="txtCode" runat="server"> </asp:TextBox>
<asp:TextBox ID="txtDesc" runat="server"> </asp:TextBox>
<asp:LinkButt on ID="lbEmpty" OnClick="lbEmpt y_Click" runat="server"> Legg
til</asp:LinkButton>
</EmptyDataTempla te>

(BTW, it is in the lbEmpty_Click method I'm trying to access the txtCode and
txtDesc textboxes. it's here the problem occur)

Any suggestions?
Nov 4 '08 #1
1 7288
try:
void lbEmpty_Click(O bject sender, EventArgs e)
{
var parent = ((Control) sender).Parent;
var txtCode = parent.FindCont rol("txtCode") as TextBox;
var txtDesc = parent.FindCont rol("txtDesc") as TextBox;
}
-- bruce (sqlwork.com)

Jeff wrote:
hi

asp.net 2.0

I have a GridView here with some controls in it's EmptyDataTempla te. I'm
wondering how I can get access to those controls. I've tryed using
FindControl, but that doesn't work because EmptyDataTempla te doesn't have
that method

<EmptyDataTempl ate>
<asp:TextBox ID="txtCode" runat="server"> </asp:TextBox>
<asp:TextBox ID="txtDesc" runat="server"> </asp:TextBox>
<asp:LinkButt on ID="lbEmpty" OnClick="lbEmpt y_Click" runat="server"> Legg
til</asp:LinkButton>
</EmptyDataTempla te>

(BTW, it is in the lbEmpty_Click method I'm trying to access the txtCode and
txtDesc textboxes. it's here the problem occur)

Any suggestions?

Nov 4 '08 #2

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

Similar topics

3
2796
by: Vivek Sharma | last post by:
Hi, I have created a dropdownlist as a web user control. I am using its multiple instances on the webpage. How do I access the selectedValue of each instance? All the instances have different IDs. Thanks Vivek
0
1226
by: rodchar | last post by:
hey all, whenever i add any kind of control to the EmptyDataTemplate and browse to that page there's like a sunken border around the control. Is there anyway to remove that? i looked at the source and there's no Div or style that i know that's telling it to do that. thanks, rodchar
0
1190
geo039
by: geo039 | last post by:
I have add functionality in my gridview footer and a detailsview in the emptydatatemplate. I need to write the same code I have for gridview_rowcommand but i'm not sure how to reference it. Basically how do i say this for a detailsview Protected Sub gridLocations_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) If e.CommandName = "Insert" AndAlso Page.IsValid Then ' Insert new record Dim roomnum As String =...
3
1574
by: Nathan Sokalski | last post by:
I have a validator that I wrote by inheriting from BaseValidator. At certain points in the code, I need to access other controls on the page containing the validator. I have the IDs of these controls, so I use the following statement to access them: Me.Page.FindControl(ControlID) However, this is returning Nothing, even though the control can be accessed in the Load event of the Page containing the control and the validator. I also...
8
10841
by: GaryDean | last post by:
I have a Wizard page and need to affect the next and previous buttons from my code-behind. I've googled around and found two solutions, and neither appear to work. I can access the SideBarList steps successfully with the following code... Control myContainer = (Control)Wizard1.FindControl("SideBarContainer"); DataList mySideBarList = (DataList)myContainer.FindControl("SideBarList");
1
1958
by: ranger979 | last post by:
I am using the emptydatatemplate for a gridview control. I have a detailsview control within the emptydatatemplate. In the detailsview I have another templatefield that contains an imagebutton control and a textbox control. <EmptyDataTemplate> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:DetailsView ID="DetailsView1"...
1
2031
by: ranger979 | last post by:
I am using the emptydatatemplate for a gridview control. I have a detailsview control within the emptydatatemplate. In the detailsview I have a templatefield that contains an imagebutton control and a textbox control. <EmptyDataTemplate> &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:DetailsView ID="DetailsView1"...
1
8830
by: bradleyhogan | last post by:
I've tried various ways to get data value(s) from a DataList control (with same results for ListView and FormView). These are my attempts: Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim dli As DataListItem For Each dli In DataList1.Items Dim theValue As String = CType(DataList1.FindControl("AttendeeMailLabel"), Label).Text ...
3
8419
by: BiffMaGriff | last post by:
Hello, I want to use the GridView footer for inserting new items into my table. However when the table is empty I'm forced to see the EmptyDataTemplate. Is there a way to disable using the EmptyDataTemplate? If not, what are some strategies for overcoming this? I'm binding to a strongly typed object data source. Thanks, -Biff
0
9474
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
10308
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...
1
10076
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
9939
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...
0
8964
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7486
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
6729
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();...
0
5375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4040
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.