473,665 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About use Container.DataI tem() in ItemTemplate

Hi all,
I try to use Container.DataI tem() in my DataGrid's ItemTemplate.
Somewhere it works fine.
eg.<input type=checkbox id='cb_select_< %# Container.DataI tem("TAG_ID")
%>' value='<%# Container.DataI tem("TAG_NAME") %>'>

but somewhere the server returns the expression was wrong.
<asp:ImageButto n id="IB_Edit<%# Container.DataI tem("TAG_ID") %>"
runat="server" ImageUrl="../Image/edit_image.gif"
CommandName="TO _EDIT"></asp:ImageButton >
or
<asp:ImageButto n id="IB_Edit" runat="server" ImageUrl="../Image/
edit_image.gif" OnClientClick=" alert('<%# Container.DataI tem("TAG_ID")
%>');" CommandName="TO _EDIT"></asp:ImageButton >

Does anyone can tell me what situation i can use this method and what
i can't?

I would appreciate any help on this.
Thank you!

Jul 2 '07 #1
3 3453
On Jul 2, 4:18 pm, alberthun...@gm ail.com wrote:
Hi all,
I try to use Container.DataI tem() in my DataGrid's ItemTemplate.
Somewhere it works fine.
eg.<input type=checkbox id='cb_select_< %# Container.DataI tem("TAG_ID")
%>' value='<%# Container.DataI tem("TAG_NAME") %>'>

but somewhere the server returns the expression was wrong.
<asp:ImageButto n id="IB_Edit<%# Container.DataI tem("TAG_ID") %>"
runat="server" ImageUrl="../Image/edit_image.gif"
CommandName="TO _EDIT"></asp:ImageButton >
or
<asp:ImageButto n id="IB_Edit" runat="server" ImageUrl="../Image/
edit_image.gif" OnClientClick=" alert('<%# Container.DataI tem("TAG_ID")
%>');" CommandName="TO _EDIT"></asp:ImageButton >

Does anyone can tell me what situation i can use this method and what
i can't?

I would appreciate any help on this.
Thank you!
Hi...

OnClientClick=" alert('<%# Container.DataI tem("TAG_ID")%> ');"
in this markup you can see you are using double " double quote to
start and end ... but in side<%# Container.DataI tem("TAG_ID")%y ou
are again using " double quote before and end of TAG_ID which is not a
well formated server tag...

your

<input type=checkbox id='cb_select_< %# Container.DataI tem("TAG_ID")
%>' value='<%# Container.DataI tem("TAG_NAME") %>'worked because in this case you started with single quote rather than double quote...
if you want to modify attributes of your itemTemplate's element... you
can always do it in itemdatabound.. ..

Thanks
Munna
www.kaz.com.bd
http://munnacs.110mb.com

Jul 2 '07 #2
<asp:ImageButto n id="IB_Edit<%# Container.DataI tem("TAG_ID") %>"
runat="server" ImageUrl="../Image/edit_image.gif"
CommandName="TO _EDIT"></asp:ImageButton >

could be written as

<asp:ImageButto n id='<%# "IB_Edit" + Container.DataI tem("TAG_ID") %>'
runat="server" ImageUrl="../Image/edit_image.gif"
CommandName="TO _EDIT"></asp:ImageButton >

And

<asp:ImageButto n id="IB_Edit" runat="server" ImageUrl="../Image/
edit_image.gif" OnClientClick=" alert('<%# Container.DataI tem("TAG_ID")
%>');" CommandName="TO _EDIT"></asp:ImageButton >

could be as

<asp:ImageButto n id="IB_Edit" runat="server" ImageUrl="../Image/
edit_image.gif" OnClientClick=' (<%# "alert(\"" + Container.DataI tem("TAG_ID")
%+ "\"");' CommandName="TO _EDIT"></asp:ImageButton >
"al**********@g mail.com" wrote:
Hi all,
I try to use Container.DataI tem() in my DataGrid's ItemTemplate.
Somewhere it works fine.
eg.<input type=checkbox id='cb_select_< %# Container.DataI tem("TAG_ID")
%>' value='<%# Container.DataI tem("TAG_NAME") %>'>

but somewhere the server returns the expression was wrong.
<asp:ImageButto n id="IB_Edit<%# Container.DataI tem("TAG_ID") %>"
runat="server" ImageUrl="../Image/edit_image.gif"
CommandName="TO _EDIT"></asp:ImageButton >
or
<asp:ImageButto n id="IB_Edit" runat="server" ImageUrl="../Image/
edit_image.gif" OnClientClick=" alert('<%# Container.DataI tem("TAG_ID")
%>');" CommandName="TO _EDIT"></asp:ImageButton >

Does anyone can tell me what situation i can use this method and what
i can't?

I would appreciate any help on this.
Thank you!

Jul 2 '07 #3
Munna, Siva
Thanks for your help!
I should be more careful:)

Albert

Jul 2 '07 #4

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

Similar topics

0
1550
by: Chumley the Walrus | last post by:
I need to assign a variable to a record drawn from a db by way of a repeater control: <ASP:Repeater id="thedata" runat="server"> <itemtemplate> <%dim display display = Container.DataItem("displaygroup") %>
1
2864
by: anony | last post by:
Hi, I would like to find out if it's possible to check the value of a Container.DataItem inside the Datagrid's <ItemTemplate> tag .... based on it's value, I would to either output it or output another DataItem from the current resultset. Something like this: <ItemTemplate> If container.dataitem( "column" ) <> "none" Then
0
993
by: Logan McKinley | last post by:
I have a datalist that takes two clicks to show the SelectedItem or UpdateItem. The first click seems to fire the event but does not seem to change the page, the second click doesn't fire the event but changes the page. I have noticed people don't bind the data on post back but when i used if(!Page.IsPostBack) to only bind the date on the first load it seems to loose everything but the date of things that have been displayed with...
5
724
by: bg | last post by:
Hi! How do I check if "date" exists before using that code? I've built a RSSreader and sometimes there's a date in it and sometimes not. How can I check if it exists to avoid crash (DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name date) <asp:DataGrid id="RssNewsGrid"
1
2282
by: Charlie | last post by:
Hi: Is it possible to apply formatting to above statements which insert field values into HTML when binding to a datasource using Repeater control? For example, I would like to trim trailing spaces. Also, I have tried things like this, but can't get them to work: <%# DataBinder.Eval(Container.DataItem, "lname") + ((DataBinder.Eval(Container.DataItem, "some_field")=="")?"":", ") + DataBinder.Eval(Container.DataItem, "fname")%>
0
880
by: Kylin | last post by:
I have a data list and bind it's datasource to a DataSet , about data item , I write a javascript that can open a custom window to show the page , but in dataitem ,I use this function , only get the '<% ', the code in the aspx page like this ? how can I use the javascript function in data item with databinder ? <asp:datalist id="DL_ProductImg" runat="server" Height="106px" RepeatColumns="2" Width="93%">
2
3393
by: Antony | last post by:
Hello, in my aspx.file I have this code inside a datagrid: <asp:TemplateColumn HeaderText="Picture"> <ItemTemplate> <asp:Image id="Image1" runat="server" ImageUrl='upload/<%# Container.DataItem("photo")%>'></asp:Image> </ItemTemplate> </asp:TemplateColumn>
1
1803
by: kelvinweb | last post by:
Hi All, Is it possible to using variable store container.dataitem in ItemTemplate ?? For example. <ItemTemplate> <% Dim x x = container.dataitem("LineNo")
4
629
by: rn5a | last post by:
When I do this: <asp:DataList ID="dlProducts" runat="server"> <HeaderTemplate> <table border="0"> <tr> <td>Category</td> <td><%# Container.DataItem("Category") %></td> </tr> </table>
0
8438
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
8348
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
8863
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
8779
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
8549
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,...
1
6187
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
5660
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
4186
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...
2
2004
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.