473,796 Members | 2,462 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Acquire control in TemplateField by Id.

zlf
Hello,
I have a GridView with TemplateField. I want to get the <asp:TextBox
ID="TextBox1" runat="server"> </asp:TextBoxin TemplateField in programmatic
way. e.g: GridView1.TextB ox1 or GridView1.FindC ontrol("TextBox 1"), but
neither of them works. Please help me.
<asp:GridView ID="GridView1" runat="server" AutoGenerateCol umns="False"
DataKeyNames="E mployeeid"
DataSourceID="O bjectDataSource 1">
<Columns>
<asp:BoundFie ld DataField="Coun try" HeaderText="Cou ntry"
SortExpression= "Country" />
<asp:TemplateFi eld HeaderText="lin k">
<ItemTemplate >
<asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>
</asp:GridView>
Thanks

zlf
Aug 24 '07 #1
3 1762
On Aug 24, 3:16 pm, "zlf" <zl...@hotmail. comwrote:
Hello,
I have a GridView with TemplateField. I want to get the <asp:TextBox
I have a suspicion that what you'd want to do would be more
interesting than
HOW to do it...

Why do you need the Control?
Is it to extract some kind of ID?

Check out this sample;
http://ajaxwidgets.com/AllControlsSa...imePicker.aspx
(Click the "Show Code for this sample")

Sure it's epcific for Gaia Ajax Widgets, but still it's the exact same
syntax with conventional APS.NET...
..t

Aug 24 '07 #2
zlf
Actually, the control I want to get is not a TextBox, it is custom control.
And I need to assign some special property of it to make it display
specified data.

"Thomas Hansen" <po*******@gmai l.com>
??????:11****** *************** *@q4g2000prc.go oglegroups.com. ..
On Aug 24, 3:16 pm, "zlf" <zl...@hotmail. comwrote:
>Hello,
I have a GridView with TemplateField. I want to get the <asp:TextBox

I have a suspicion that what you'd want to do would be more
interesting than
HOW to do it...

Why do you need the Control?
Is it to extract some kind of ID?

Check out this sample;
http://ajaxwidgets.com/AllControlsSa...imePicker.aspx
(Click the "Show Code for this sample")

Sure it's epcific for Gaia Ajax Widgets, but still it's the exact same
syntax with conventional APS.NET...
.t

Aug 24 '07 #3
This is probably what you were looking for.

protected void GridView1_RowDa taBound(object sender, GridViewRowEven tArgs e)
{
TextBox c = (TextBox) e.Row.FindContr ol("TextBox1") ;
if (c!=null)
{
// set properties
}
else
{
// did not find or was binding Footer/Headers etc.
}
Int32 d = 0;
}

YUou also can bind properties declaratively using Eval or Container.DataI tem

"zlf" wrote:
Hello,
I have a GridView with TemplateField. I want to get the <asp:TextBox
ID="TextBox1" runat="server"> </asp:TextBoxin TemplateField in programmatic
way. e.g: GridView1.TextB ox1 or GridView1.FindC ontrol("TextBox 1"), but
neither of them works. Please help me.
<asp:GridView ID="GridView1" runat="server" AutoGenerateCol umns="False"
DataKeyNames="E mployeeid"
DataSourceID="O bjectDataSource 1">
<Columns>
<asp:BoundFie ld DataField="Coun try" HeaderText="Cou ntry"
SortExpression= "Country" />
<asp:TemplateFi eld HeaderText="lin k">
<ItemTemplate >
<asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>
</ItemTemplate>
</asp:TemplateFie ld>
</Columns>
</asp:GridView>
Thanks

zlf
Aug 24 '07 #4

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

Similar topics

1
9113
by: Zule | last post by:
Hi, I am creating a Composite Control within which I have a GridView. In this GridView, I have three TemplateFields, the last one being a template with a LinkButton which is meant to be clicked so I can capture this event to do something about it. The problem is that in the CreateChildControls method, I initialize the GridView and link its RowCommand event to a method (so I can capture the LinkButton Click) but it doesn't work... I put...
5
2767
by: Siva | last post by:
Hello I have a dropdownlist inside the gridview as a template column defined as follows: <asp:TemplateField HeaderText="Choose Location"> <ItemTemplate> <asp:DropDownList ID="ddlChooseLoc" runat="server"> </asp:DropDownList> </ItemTemplate> </asp:TemplateField> I have the gridview inside of a master page- content hierarchy.
1
10445
by: Nam | last post by:
I have a DropDownList control in a TemplateField inside my GridView How do I access this control’s SelectedIndexChanged event in codeBehind page? I don’t see the ID “DropDownList1” of this control in the list of objects in odeBehind page. GridView1 and DropDownList1 are bound to TWO DIFFERENT tables (DataSources). The last column of each row in the GridView is shown as a DropDownList. I want to use the SelectedIndexChanged ...
2
2200
by: Ben | last post by:
Hi, In the code-behind, i can refer to the dropdownlist defined in the aspx file with this (e.g.) dropdownlist1.sekectedvalue = ... but why can i not refer to the label defined in the TemplateField in the same aspx file like below? This gives the error: "can't find control 'mylabel' ": mylabel.text="ok"
3
7420
parshupooja
by: parshupooja | last post by:
Hey All, I am trying to used Masked Edit controls of Ajax in gridview. I have 14 rows in gridview,but masked edit control only works for first row. Any Idea. Plz Help <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="gvOnRowDataBound" CellPadding="6" CssClass="GridStyle" Width="600" ShowFooter="True"> <RowStyle CssClass="GridItem" /> <AlternatingRowStyle CssClass="GridAltItem" />...
2
2484
by: Danielle | last post by:
Hello all - Thank you in advance for any help you are able to provide. I am populating a gridview from a stored procuedure. The returned data is a name, phone number, email and guid of a contact in our database. I also need to use the Edit and Delete funtions in the gridview. Neither seems to be working as intended.
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"...
3
2043
by: kimbred | last post by:
Can someone help? I have the code below in which I'm attempting to show or hide the edit control in a gridview based on the value of a column in that view. It doesn't seem to find the control. I've included the RowDataBound event as well as the gridview definition. Thanks in advance. protected void gvEmployeesBenefits_RowDataBound(object sender, GridViewRowEventArgs e) { TextBox EditFlg = (TextBox)...
0
9683
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10231
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...
0
10013
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
9054
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 projectplanning, coding, testing, and deploymentwithout 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
7550
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
6792
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
5443
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
4119
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
3
2927
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.