473,763 Members | 8,483 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic TemplateField

Hi,

How can I convert this in c# code ?

<asp:TemplateFi eld HeaderStyle="10 0">
<ItemTemplate >
<a href="#" onclick="<%#fun cDelete(Contain er.DataItem)%>" >Delete</a>
</ItemTemplate>
</asp:TemplateFie ld>

Thanks in advance.

Stan

Jun 16 '07 #1
1 3276
That's okay, It's done..

Here's what I code.
I don't know if I could optimize this..

public class gTemplate : ITemplate
{
public gTemplate(){}
public InstantiateIn(S ystem.Web.Ui.Co ntrol.container )
{
Literal myLnk= new Literal();
myLnk.DataBindi ng+=new EventHandler(th is.Id_DataBindi ng);
container.Contr ols.Add(myLnk);
}
private void Id_DataBinding( Object sender, EventArgs e)
{
Literal myLiteral = (myLiteral) sender;
GridViewRow myRow (GridViewRow) myLiteral.Namin Container;
myLiteral="<a href=\"#\" onclick="myFunc tion('"+
DataBinder.Eval (myRow.DataItem ,"Id").ToString ()+"')\">Delete </a>";
}
}
And I add to the gridview

TemplateField myTemplate=newT emplateField();
myTemplate.Item Style.Width=100 ;
myTemplate.Item Template=new gTemplate();
myGridView.Colu mns.Add(myTempl ate);

Stan

"Stan SR" <st**@pasdepam. netsunset.coma écrit dans le message de
news:Ou******** ******@TK2MSFTN GP06.phx.gbl...
Hi,

How can I convert this in c# code ?

<asp:TemplateFi eld HeaderStyle="10 0">
<ItemTemplate >
<a href="#"
onclick="<%#fun cDelete(Contain er.DataItem)%>" >Delete</a>
</ItemTemplate>
</asp:TemplateFie ld>

Thanks in advance.

Stan
Jun 16 '07 #2

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

Similar topics

4
5043
by: Larry Grady | last post by:
Anyone up for a challenge? I've been struggling with this for a few days and was hoping someone could help me. Pouring through all the messageboards I just can't find the solution. We have a GridView that needs to be dynamically designed, depending on what collection of fields our uses want to edit for their product data. We have 400+ fields of information per product so they're selecting a subset of those fields to edit.
2
10296
by: sck10 | last post by:
Hello, I am trying to programically make the following TemplateField ("MyTemplate") visible when the user clicks on the "Edit" Button using the PreRender handle event. My question is, how do you reference the properties of a particular TemplateField? For example: Protected Sub dvDetail_PreRender(ByVal sender As Object, ByVal e As EventArgs) Handles dvDetail.PreRender If Me.dvDetail.CurrentMode = DetailsViewMode.Edit Then
3
13753
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum. Everyone wants to do a java confirmation box when a user clicks the delete button. Fair enough, basic user design rules state that you should always confirm a delete action. There is also a consensus that the best way to do this is a template...
1
2290
by: sloan | last post by:
I am programmatically adding BoundField's and TemplateField's to a GridView. I have it working fine. BoundField bf = new BoundField(); bf.DataField = "EmpID"; bf.HeaderText = "The Employee ID";
4
4900
by: Deere | last post by:
When I try to take a database field and change it with a function and return it...it will not display the image. The "Imageurl" does not convert to "src=" but stays as ImageUrl. id=Image2 will display ok ..and shows in view source as ....... <img id="gvwExample_ctl07_Image2" src=".\images\toys\1_16\thumb\t_15511.jpg" style="border-width:0px;" />
2
17044
by: =?Utf-8?B?dmFuZGls?= | last post by:
I have a web app that I have been working on for the last couple of weeks trying to solve this problem. One page contains a GridView with four base columns, and an unknown number of columns to be added depending on the data source chosen. I create some TemplateColumns based on the data returned for the selection, and add them into the GridView using the following code: DataSet dsTraits = ssql_common.selectRubricTraits(sConnectionString,...
6
2259
by: Class | last post by:
Hi all, I create a gridview dynamicly because I don't know the columns in advance. I use the Templatefield to create a linkbutton. Everything fine..I have the postbackurl and it works. But now I need to do some extra stuff in the click event of the created linkbutton. I tried to assign a delegate to the linkbutton's click event but I never gets in the procedure I assign. How can I trap the click event?
7
12956
by: rote | last post by:
I would like to make my Gridview header dynmic i.e databinded from database.. I want my users to be able to change the headers on the fly.. Any ideas?
12
24813
by: ive1122 | last post by:
Hi guys, I am looking into create a dynamic survey as posted in Get User Input From Dynamic Controls but with some different environment Below is what i am trying to do: First when the user click the button, it will populate a dynamic table with radio button for the survey questionnaire However, i was unable to get its value (for score calculation) after clicking the submit button Beside i am using an ajax extension (updatePanel) for the...
0
9564
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
10148
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
9938
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
9823
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
7368
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
6643
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
5270
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
3917
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
2794
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.