473,396 Members | 1,968 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.

Dynamic Links

I have a data repeater controll on a page. in each row that is displayed, I
would like to have an action column that has differnet links shown depending
on certain criteria from the database. In traditional asp you could check
the value as you looped through the recordset, but in asp.net I am not sure
how to do it if you are binding to a control.

Thanks,
Chad
Nov 18 '05 #1
3 1579
Hi,

you could use helper function or handle the ItemDataBound event of the
Repeater and manage the items from there (one by one)

See this article for info about helper functions (they are general concept
with databound controls like DataGrid,DataList and Repeater)

http://www.aspalliance.com/31

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Chad THomas" <ct*****@echosat.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have a data repeater controll on a page. in each row that is displayed, I would like to have an action column that has differnet links shown depending on certain criteria from the database. In traditional asp you could check
the value as you looped through the recordset, but in asp.net I am not sure how to do it if you are binding to a control.

Thanks,
Chad

Nov 18 '05 #2
Hi Chad,

Teemu has a great answer. You can also use the repeater's ItemDataBound
event. This event fires for each row in the repeater (one by one).

Here's a small sample that demonstrates a little of what you can do in this
event.

*** Here is my repeater control
<asp:Repeater id="Repeater1" runat="server">
<ItemTemplate>
<input id=one name=one type=text runat=server value=
'<%# Container.DataItem("au_id")%>'> &nbsp;
<br>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
*** Here is my code
Dim Counter As Integer = 0

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Bind()
End If
End Sub

Private Sub Bind()
Dim Qry1 As System.Data.SqlClient.SqlDataReader
Dim connectionString As String = "server='localhost';
trusted_connection=true; Database='pubs'"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New
System.Data.SqlClient.SqlConnection(connectionStri ng)
Dim queryString As String = "SELECT au_id, au_lname, au_fname FROM
authors"
Dim sqlCommand As System.Data.SqlClient.SqlCommand = New
System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlConnection.Open()
Qry1 =
sqlCommand.ExecuteReader(System.Data.CommandBehavi or.CloseConnection)
Repeater1.DataSource = Qry1
Repeater1.DataBind()
Qry1.Close()
sqlCommand.Dispose()
sqlConnection.Close()
sqlConnection.Dispose()
End Sub

Private Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.RepeaterItemEventArgs) Handles
Repeater1.ItemDataBound
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then
If e.Item.DataItem("au_lname") = "Green" Then
Dim l As LinkButton = New LinkButton
l.Text = e.Item.DataItem("au_lname")
l.ForeColor = System.Drawing.Color.Green()
e.Item.Controls.Add(l)
End If
Counter += 1
End If
If e.Item.ItemType = ListItemType.Footer Then
Dim t As TextBox = New TextBox
t.Text = Counter.ToString & " People"
t.ForeColor = System.Drawing.Color.Green()
t.ReadOnly = True
e.Item.Controls.Add(t)
End If
End Sub

I hope this helps.

Thank you, Mike
Microsoft, ASP.NET Support Professional

Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer’s security.

This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
From: "Chad THomas" <ct*****@echosat.com>
Subject: Dynamic Links
Date: Wed, 17 Dec 2003 14:38:36 -0500
Lines: 10
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#2**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 12.158.50.129
Path: cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTN GXA05.phx.gbl!TK2MSFTNGP08
..phx.gbl!TK2MSFTNGP11.phx.gbl Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:196986
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

I have a data repeater controll on a page. in each row that is displayed, I would like to have an action column that has differnet links shown depending on certain criteria from the database. In traditional asp you could check
the value as you looped through the recordset, but in asp.net I am not sure how to do it if you are binding to a control.

Thanks,
Chad


Nov 18 '05 #3
I did that and it worked great. thanks for all the help.
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:u0**************@TK2MSFTNGP10.phx.gbl...
Hi,

you could use helper function or handle the ItemDataBound event of the
Repeater and manage the items from there (one by one)

See this article for info about helper functions (they are general concept
with databound controls like DataGrid,DataList and Repeater)

http://www.aspalliance.com/31

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"Chad THomas" <ct*****@echosat.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have a data repeater controll on a page. in each row that is displayed,
I
would like to have an action column that has differnet links shown

depending
on certain criteria from the database. In traditional asp you could

check the value as you looped through the recordset, but in asp.net I am not

sure
how to do it if you are binding to a control.

Thanks,
Chad


Nov 18 '05 #4

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

Similar topics

3
by: Danny | last post by:
How do you guys make listings such as product listings and their detail pages more crawler friendly, if they are genrated using dynamic asp pages. If your ASP uses a format like this:...
1
by: Guinness Mann | last post by:
When you guys talk about "dynamic SQL," to what exactly are you referring? Is dynamic SQL anything that isn't a stored procedure? Specifically, I use ASP.NET to communicate with my SQL Server...
2
by: Glenn | last post by:
Dynamic help topic links show properly and search brings up links, but when any link is clicked I receive a "Page Cannot be displayed message in the Explorer window and the title bar of Visual...
3
by: Steve | last post by:
Hi- I am interested in creating links within my pages dynamically as they are requested. For example, someone requests a page, my web app. would parse the generated *.aspx HTML and add links to...
8
by: Sandy Pittendrigh | last post by:
I have a how-to-do-it manual like site, related to fishing. I want to add a new interactive question/comment feature to each instructional page on the site. I want (registered) users to be able...
3
by: Peter K | last post by:
Hi I need to make a list of "download file links" on a webpage. All the data is dynamic - it depends on the user's actions how many files, and which files, I need to present in the list. The...
2
by: thetechturf.com | last post by:
I have some simple dynamic content pages (included below). I need to know how to add specific meta tags (ie. description, keywords, ect.), as well as extra specific header coding to a page. I would...
9
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I...
12
by: Lazoris | last post by:
OK heres a newb question and I'm sorry for it, but im getting back into web design after like 5 years off and im stuck even though i should know the problem i cant seem to correct it atm. What I'm...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.