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

About use Container.DataItem() in ItemTemplate

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

but somewhere the server returns the expression was wrong.
<asp:ImageButton id="IB_Edit<%# Container.DataItem("TAG_ID") %>"
runat="server" ImageUrl="../Image/edit_image.gif"
CommandName="TO_EDIT"></asp:ImageButton>
or
<asp:ImageButton id="IB_Edit" runat="server" ImageUrl="../Image/
edit_image.gif" OnClientClick="alert('<%# Container.DataItem("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 3436
On Jul 2, 4:18 pm, alberthun...@gmail.com wrote:
Hi all,
I try to use Container.DataItem() in my DataGrid's ItemTemplate.
Somewhere it works fine.
eg.<input type=checkbox id='cb_select_<%# Container.DataItem("TAG_ID")
%>' value='<%# Container.DataItem("TAG_NAME") %>'>

but somewhere the server returns the expression was wrong.
<asp:ImageButton id="IB_Edit<%# Container.DataItem("TAG_ID") %>"
runat="server" ImageUrl="../Image/edit_image.gif"
CommandName="TO_EDIT"></asp:ImageButton>
or
<asp:ImageButton id="IB_Edit" runat="server" ImageUrl="../Image/
edit_image.gif" OnClientClick="alert('<%# Container.DataItem("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.DataItem("TAG_ID")%>');"
in this markup you can see you are using double " double quote to
start and end ... but in side<%# Container.DataItem("TAG_ID")%you
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.DataItem("TAG_ID")
%>' value='<%# Container.DataItem("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:ImageButton id="IB_Edit<%# Container.DataItem("TAG_ID") %>"
runat="server" ImageUrl="../Image/edit_image.gif"
CommandName="TO_EDIT"></asp:ImageButton>

could be written as

<asp:ImageButton id='<%# "IB_Edit" + Container.DataItem("TAG_ID") %>'
runat="server" ImageUrl="../Image/edit_image.gif"
CommandName="TO_EDIT"></asp:ImageButton>

And

<asp:ImageButton id="IB_Edit" runat="server" ImageUrl="../Image/
edit_image.gif" OnClientClick="alert('<%# Container.DataItem("TAG_ID")
%>');" CommandName="TO_EDIT"></asp:ImageButton>

could be as

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

but somewhere the server returns the expression was wrong.
<asp:ImageButton id="IB_Edit<%# Container.DataItem("TAG_ID") %>"
runat="server" ImageUrl="../Image/edit_image.gif"
CommandName="TO_EDIT"></asp:ImageButton>
or
<asp:ImageButton id="IB_Edit" runat="server" ImageUrl="../Image/
edit_image.gif" OnClientClick="alert('<%# Container.DataItem("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
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 =...
1
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...
0
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...
5
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...
1
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...
0
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...
2
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/<%#...
1
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.