473,320 Members | 1,794 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,320 software developers and data experts.

accessing control in EmptyDataTemplate

hi

asp.net 2.0

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

<EmptyDataTemplate>
<asp:TextBox ID="txtCode" runat="server"></asp:TextBox>
<asp:TextBox ID="txtDesc" runat="server"></asp:TextBox>
<asp:LinkButton ID="lbEmpty" OnClick="lbEmpty_Click" runat="server">Legg
til</asp:LinkButton>
</EmptyDataTemplate>

(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 7262
try:
void lbEmpty_Click(Object sender, EventArgs e)
{
var parent = ((Control) sender).Parent;
var txtCode = parent.FindControl("txtCode") as TextBox;
var txtDesc = parent.FindControl("txtDesc") as TextBox;
}
-- bruce (sqlwork.com)

Jeff wrote:
hi

asp.net 2.0

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

<EmptyDataTemplate>
<asp:TextBox ID="txtCode" runat="server"></asp:TextBox>
<asp:TextBox ID="txtDesc" runat="server"></asp:TextBox>
<asp:LinkButton ID="lbEmpty" OnClick="lbEmpty_Click" runat="server">Legg
til</asp:LinkButton>
</EmptyDataTemplate>

(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
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...
0
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...
0
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...
3
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...
8
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...
1
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...
1
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...
1
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,...
3
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.