Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 3rd, 2004, 12:26 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
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

  #2 (permalink)  
Old August 3rd, 2004, 02:04 PM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
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.
  #3 (permalink)  
Old August 3rd, 2004, 07:44 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Raif
Default

Cool got it. Thanks Mehdi!

  #4 (permalink)  
Old August 19th, 2004, 11:37 AM
Registered User
 
Join Date: Aug 2004
Location: , , United Kingdom.
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

  #5 (permalink)  
Old August 19th, 2004, 12:41 PM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
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.:)
  #6 (permalink)  
Old August 19th, 2004, 02:20 PM
Registered User
 
Join Date: Aug 2004
Location: , , United Kingdom.
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

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:32 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.