Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 3rd, 2004, 12:26 PM
Authorized User
 
Join Date: Jun 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Raif
Default is it possilble to do logic inside an itemtemplate

Hi, I have a cell in a datagrid which looks like this
<TD style="FONT-SIZE: 10pt"><%# databinder.eval(container.dataitem,"s1cl")%></TD>
What I need to do is perform some logic on the value, such as: if the value (databinder.eval(container.dataitem,"s1cl") = somestring then display this otherstring instead of origional value. I know how to form the if then statement. What I don't know is how or where to place it. In the codebehind or in the html or both? and how.
Thanks for you help
Raif

 
Old August 3rd, 2004, 02:04 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

you can chang <TD> tag to server-side so you could access it better.
----
<TD style="FONT-SIZE: 10pt" runat=server ID="TD1"><%# databinder.eval(container.dataitem,"s1cl")%></TD>
----
Then in your codebehind you can use it i.e in your ItemCommand event of your DataGrid
----
private void DataGrid1_ItemCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
((HtmlTableCell)e.Item.FindControl("TD1")).InnerTe xt=newValue;
}
----
HTH.

--------------------------------------------
Mehdi.
 
Old August 3rd, 2004, 07:44 PM
Authorized User
 
Join Date: Jun 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Raif
Default

Cool got it. Thanks Mehdi!

 
Old August 19th, 2004, 11:37 AM
Registered User
 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, ive got a similar question, but im using a repeater control instead of a data grid, if i want to add a hyper link depending on the data from a sql quieries how should i do it, this is what i do at the moment =
 <div align="center"><a href="viewuser.aspx?id=<%# Container.DataItem("fldUserId") %>"><%# Container.DataItem("fldUName") %></a></div>
But if i want to not show the fldUName as a hyperlink for a specific value how do i do that?

Also hi to this forum ive just joined and thanks fo anyones reply

 
Old August 19th, 2004, 12:41 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Welcome,
well,u can bind it to another object like below...
<div align="center"><a href="viewuser.aspx?id=<%# Container.DataItem("fldUserId") %>"><%# TextBox1.Text %></a></div>
HtH.

--------------------------------------------
Mehdi.:)
 
Old August 19th, 2004, 02:20 PM
Registered User
 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi thanks for your reply, ive changed my tactics i'm now using the OnItemDataBound event for the repeater
<asp:repeater ID="forumRepeater" OnItemDataBound="forumRepeater_ItemDataBound" runat="server">

and calling the following function

Private Sub forumRepeater_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.RepeaterItemEventArgs)
       if not e.Item.DataItem("fldUName") = "Guest" then
            response.Write("hello<br>") <--- for testing
       End If
    End Sub
but as i am calling the sub from the repeater control how do i get hold of the objects to pass to the function.
I ask this as im getting an error, it works fine in vs.net using codebehind, but im using Dreamweaver with the code on the page.

Thanks in advance






Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView Checkbox ItemTemplate angelicagm ASP.NET 2.0 Professional 3 May 31st, 2007 04:44 AM
dropdownlist inside a datalist's itemtemplate stu9820 ASP.NET 1.0 and 1.1 Basics 2 April 26th, 2007 05:53 PM
How to Use ItemTemplate Editor wirerider ASP.NET 2.0 Basics 0 February 18th, 2006 02:59 PM
Mixing Data access logic and business logic polrtex BOOK: Professional Jakarta Struts 0 December 15th, 2003 07:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.