Forms Data Controls :: Conditionally Create A Hyperlink Within A Repeater ItemTemplate?

Dec 12, 2010

using a repeater to display multiple 'comments' related to a parent database entity (a 'task' in my case). When the user creates these comments they can optionally attach a file. Now, I'm working on the page that lists these comments and I'm not sure how to go about displaying the link to the attached file, if one is present. There may not be a file. The database record that contains the comment will also contain the url to the file if one was attached.

what are my options for this? I would like to just display a link to the file after the comment content, only if a file is available.

View 11 Replies


Similar Messages:

Forms Data Controls :: Show Hyperlink On Condition In Repeater ItemTemplate

Nov 2, 2010

I have a Repeater displaying some data that doesn't do what I'd like to see. If a certain condition is met (ex: parent.NumOfChildren > 0) I would like a hyperlink shown. Here is what I have so far:

<asp:Repeater ID="parents" runat="server" >
<ItemTemplate>
<asp:HyperLink NavigateUrl='<%# "Children.aspx?parent=" &#43; DataBinder.Eval(Container.DataItem,"Parent_ID")%>'
Text='View Children' runat="server" target="_self" ID="Hyperlink2" NAME="Hyperlink2"/> -
</ItemTemplate>
</asp:Repeater>

In this case, the "View Children" link shows up for every item in my Repeater, but I'd like it shown only if parent.GetNumOfChildren() > 0. Would it be correct to try setting the Visible="true/false" property of the HyperLink? Is that the norm for this sort of problem? Or, is there a way to wrap the entire <asp:Hyperlink> ... </asp:Hyperlink> tag in an if statement that has a reference to the object that is currently being interated in the Repeater? Ie:

if(CurrentDataItemInIteration.GetNumOfChildren() > 0)
{
<asp:Hyperlink> ..... </asp:Hyperlink>
}

To me, the Visible="true/false" solution seems cleaner, if possible.

View 5 Replies

Forms Data Controls :: Repeater ItemTemplate To Create A Div Container

Apr 16, 2010

In my application I have successfully pulled some rows from a database into a DataSet and then used an ASP.NET Repeater Control to create a div container for each row with each field contained within a span element as follows:

<asp:Repeater
id="repeater"
runat="server">
<ItemTemplate>
<div
id="ticketContainer">
<a
href="#"><img
src="~/Images/treeview_expand.png"
alt=""
runat="server"
/></a>
<span><%#DataBinder.Eval(Container.DataItem,
"USERNAME")%></span>
<span><%#DataBinder.Eval(Container.DataItem,
"COMPUTERNAME")%></span>
<span><%#DataBinder.Eval(Container.DataItem,
"CATEGORY")%></span>
<span><%#DataBinder.Eval(Container.DataItem,
"DATE")%></span>
<span><%#DataBinder.Eval(Container.DataItem,
"TIME")%></span>
<span><%#DataBinder.Eval(Container.DataItem,
"STATUS")%></span>
<p><%#DataBinder.Eval(Container.DataItem,
"DESCRIPTION")%></p>
</div>
</ItemTemplate>
</asp:Repeater>

My problem is that I want the .png graphic link to have a onclick event so that a new div is dynamically inserted under the div to show data from a seperate database table. However since its all declared within the ItemTemplate then targeting the correct div using the JS DOM would be difficult/impossible as the id for each of the divs will be the same.

If this is going to be infeasible then what is the possibility of having data brought in from multiple tables would I have to manipulate the DataSet to include the extra columns as I think Repeater Controls can only have a single DataSet (corret me if i'm wrong).

View 3 Replies

Forms Data Controls :: Can Conditionally Display Hyperlink In A Gridview Column

Jan 4, 2011

i have a gridview of a list of VehicleRequisition's with a column whose itemtemplate is as follows.

[Code]....

[Code]....

View 2 Replies

Forms Data Controls :: Repeater Paging - Retrieve Hyperlink Variable Inside Repeater?

Jul 12, 2010

I have repeater in which I have 2 hyperlink in the footer of the repeater and I want that the hyperlink can navigate from the page_load

View 2 Replies

Forms Data Controls :: Hide Hyperlink Within ItemTemplate?

Aug 27, 2010

If there is no value in the database, I would like to hide my hyperlink within a gridview. Here's what I have:

visible='<%# Eval("my_field").Is Not Null %>'

Of course the Is Not Null doesnt work, is there something I can do to check:

1) if not null then set visible true

2) if null then set visible to false

View 2 Replies

Forms Data Controls :: Hyperlink Inside An ItemTemplate?

Jul 15, 2010

I have a DataGridView with a ItemTeplate column, which has a HTML hyperlink (<a href....>) inside. When a user clicks on a link, a popup with a TextBox is showed to the user. Then the user can type a data. With this data, I must update the hyperlink's text in which the user clicked. All using javascript. The problem is that I don't know how to find the Hyperlink because there will be so many hyperlinks as rows in the DataGridView and they will have the same Id.

How can i find the hyperlink using javascript?

View 4 Replies

Forms Data Controls :: Add Sum Of Gridviews ItemTemplate Hyperlink Field To Footer?

Mar 3, 2010

[Code]....

Above is the field in the gridView. My question is very simplet that whatever the number of rows in a grid in one column, I just want to show the sum of the values of a column in the Footer Row.

I don't want to use javascript. I have tried following code but there is displaying "0" in the footer of the respect column instead of sum.

[Code]....

I need assistance in the code which I provided. I want something like this:

20+30+10 =60

but it is displaying like:

20+30+10=10

View 10 Replies

Forms Data Controls :: ItemTemplate - Hide A Hyperlink Based On The Value Of A Column?

Apr 1, 2011

I have a gridview and in the gridview i have a an itemtemplatefield with a regular html hyperlink in it.

Based on the value of one of the columns in the gridview, i want to hide this hyperlink and just replace it with the value of another column

e.g. <a href="page.aspx?x=<%=Me.CurrentAgent.ID %>&id=<%# Eval("Id") %><%# Eval("Customer") %></a>

if Eval("Status") = 123 then instea of the above hyperlink, i just want <%# Eval("Customer") %>

View 2 Replies

Forms Data Controls :: Repeater With A Tag In The ItemTemplate

Jun 22, 2010

I have tried many different combinations to try to get this to work, but I cannot. In the ItemTemplate of a Repeater control, I have a <form> tag. For this third party button to work, each button needs to be surrounded by <form></form> tags. I cannot get the first iteration of the repeater to display the tag, but 2, 3 and beyond, it will. It doesn't make sense to me. Because of this, IE is displaying the page in a funky way.

To see the generated code on the page, http://AdvancedSurveillancePro.com/services.aspx

Here is my repeater code:

[Code]....

View 3 Replies

Forms Data Controls :: Using Rowspan In ItemTemplate Of Asp:repeater

Feb 22, 2011

I have the following problem and I hope some of you could help me because I'm sick and tired of trying to get this fixed.

I have an asp:repeater which has the following <ItemTemplate>

[Code]....

[Code]....

[Code]....

[Code]....

[Code]....

but it really looks like this.

View 1 Replies

Forms Data Controls :: Work With Repeater Itemtemplate Coding?

Feb 7, 2010

I have the following code in an aspx form for an asp:Repeater

<ItemTemplate>
<tr class='<%#Container.ItemIndex % 2 == 0 ? "normalRow" : "alternateRow" %>' >
<tr>
<td>
<asp:LinkButton ID="LinkButton1" runat="server">blabla
<%#DataBinder.Eval(Container.DataItem, "ListName")%>
</asp:LinkButton>
</td>
</tr>
</ItemTemplate>

Which produces a syntax error (and a sqiggle blue underline) on

<%#Databinder.Eval(Container.DataItem, "ListName")%>

the build tells me I have an invalid character in the position before the opening <%
above

This only happens after I add the conditional class for the <tr> tag

"<tr class='<%#Container.ItemIndex..."

before I add the above line (to replace the <AlternatingItemTemplate>) everythings ok.

View 4 Replies

Forms Data Controls :: How To Alter A Control In A Repeater's ItemTemplate From A Handler

Mar 27, 2010

I have a repeater bound to a datasource that servers as a list of birds. When the user clicks an item in the list the bird's image is displayed on the page. I want to change the background color of the item that is currently selected in the OnClick handler for the main item in my repeater's ItemTemplate.

I have changed the styling of controls prgrammatically before and it worked fine but in those cases i used the ID of the control to directly access it in my code behind file. But since this is some arbitrary item in a repeater I don't know it's ID at runtime, all I have is the sender object passed to the control's OnClick handler. So in my code behind file, I tried casting the sender object passed to the OnClick handler to the appropriate type and used Style.Add("background-color", highlitColor) but it failed to change anything.

I had a thought - maybe this sender object gets passed by value so all I did was change the Style of a COPY of the control item.

If this is indeed my problem, how do I start with a casted sender object in an event handler and get a reference to the actual control in order to change it's Style?

View 13 Replies

Forms Data Controls :: Pass Variable With Repeater Hyperlink URL

Jan 15, 2010

I query the database to get the VideoName and VideoURL of the videos held in my database (Videos saved on the file system with their location stored in the database) then bind the query results to a repeater with the following code

protected void Page_Load(object sender, EventArgs e)
{
// Variables declaration
string strConnString = ConfigurationManager.ConnectionStrings["vidConnectionString"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(strConnString);
SqlCommand sqlcmd = new SqlCommand("SELECT [VideoName], [VideoURL] FROM [Video]");
SqlDataReader sqlReader;
sqlConn.Open();
sqlcmd.Connection = sqlConn;
sqlReader = sqlcmd.ExecuteReader();
VideoRepeater.DataSource = sqlReader;
VideoRepeater.DataBind();
sqlConn.Close();
}

and put a hyperlink into the repeater to list all the VideoName's this works fine but I want to pass the VideoURL to the next page I am using NavigateUrl="PlayVideo.aspx?VideoURL='<%# Eval("VideoURL") %>'" but when I try and load the Page I get the error saying The server tag is not well formed. the whole repeater code is

<asp:Repeater ID="VideoRepeater" runat="server" >
<ItemTemplate>
<asp:HyperLink ID="VideoLink" NavigateUrl="PlayVideo.aspx?VideoURL='<%# Eval("VideoURL") %>'" runat="server"><%# Eval("VideoName") %></asp:HyperLink>
</br>
</ItemTemplate>
</asp:Repeater>

I'm sure i've just got the hyperlink navigateURL wrong put not sure how else to pass the VideoURL variable

View 9 Replies

Forms Data Controls :: Hyperlink In Repeater - Get Masterpage Property A Value

Jan 10, 2010

i have a a public property in my masterpage, I have a repeater on another page which has a hyperlink, when i click on it, i need to give the masterpage property a value based on the hyperlink clicked. How do i go about doing this, because at the moment the property is set to the last value in the repeater. I have something like this;

[Code]....

View 5 Replies

Forms Data Controls :: Use Hyperlink With Repeater - Links Are Not Evaluated Well

Nov 28, 2010

I have a repeater in my page as follows:

<asp:Repeater ID="RepeaterVacancies" runat="server">
<ItemTemplate>
<asp:TableCell CssClass="evenTd" runat="server">
<asp:HyperLink runat="server" NavigateUrl="Vacancies.aspx?VID=<%#DataBinder.Eval(Container.DataItem,'id')%>"
ID="Hyperlink1">
<%# Container.ItemIndex &#43; 1 %>
</asp:HyperLink>
</asp:TableCell>
......
</ItemTemplate>
</asp:repeater>

when I loaded the page, the numbers come fine, but the links are not evaluated well: Instead of linking to Vacancies.aspx?VID=170 for example, the link comes this way: [URL]

View 3 Replies

Forms Data Controls :: Checks Hyperlink In A Repeater And If The File Exists

Feb 26, 2010

I want to create C# code that checks a hyperlink in a repeater and checks if the file exists. If not, the hyperlink is not visible. The path and document ar pulled from a sqldatasource:

[Code]....

View 2 Replies

Forms Data Controls :: Hyperlink Control Inside Repeater Events?

Aug 9, 2010

I need to list URL records from DB and bind data to repeater, therefore I put hyperlink inside repeater control.

I want to fire 2 events when a Visitor click on hyperlink

1- It Update DB Record that this link clicked one time

2-Open URL in new windows

View 7 Replies

Data Controls :: Export Repeater Control With TextBox In ItemTemplate To Excel

Jul 17, 2015

I have a repeater control that is getting exported to excel. Well excel will no longer show the data that was in the textboxes. I've read the article on exporting a gridview having the same problem and how you replace the texboxes with literal contrls. I was wondering if there is an article like it only for a repeater control.

View 1 Replies

Forms Data Controls :: How To Change A Repeater Hyperlink Text Depending On The ID Of The Item

Feb 25, 2010

I have a repeater control that loads my data ok. I have a hyper link field in my repeater control. It looks like this:

[Code]....

View 3 Replies

Forms Data Controls :: Creating A Single Item From Two Data Fields In A HYPERLINK Control Within A Repeater...

Jun 22, 2010

I am trying to use a repeater control that will display a hyperlink control. For the text of that Hyperlink control I would like to concatenate to fields from my data source (lets say First Name and Last Name). How would I do this appropriately for the Hyperlink control within an ItemTemplate?

View 3 Replies

Forms Data Controls :: Repeater ItemTemplate - If Eval(field)=0 Then HTML Else HTML

Feb 20, 2010

The following seems reasonable, but it returns an error:

<asp:Repeater ID="RepeaterF" runat="server" DataSourceID="DSF" >
<ItemTemplate>
<%
If Eval("Item_Batch") = 0 Then
%><tr><td></td><td colspan="2"></td><td></td></tr><%
Else %>........

Error: "Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control."

I am finding it difficult to accept that the whole Repeater approach has any benefits over just creating a loop in code, iterating through a recordset, and building a html table into a variable, then dumping it to the page. This repeater is spawning pages of code and objects, and surely this is all using up server resources.

View 2 Replies

Forms Data Controls :: Create Texbox In Datatable - Without Using Gridview Itemtemplate?

Apr 8, 2010

i have gridview resulted from sql query as below:

customer_id
items
123
pen
123
paper
456
pen
456
paper
678
pen

then i pivot the gridview by using the datatable.. i call the sql query to the datatable, pivot it using pivoted function and the datatable then become the datasource bind to the gridview..the result of pivoted datatable in gridview as below:

customer_id
pen
paper
123
(empty)
(empty)
456
(empty)
(empty)
678
(empty)
(empty)

my question is..how can i replace the empty column with textbox to be display within the gridview??? i need to use textbox so that user may enter the value of the item within the textbox.. i try using the itemtemplate for gridview but it's doesn't work and the itemtemplate create new column with textbox beside the paper column.. how to input textbox within the datatable in my case??

View 1 Replies

Forms Data Controls :: How To Create Rows And Column Using Datatable Gridview Itemtemplate With Multi Header

Feb 23, 2010

How to create Rows and Column using Datatable Gridview Itemtemplate with multi header I need to create Datatable Gridview Itemtemplate fixed rows and column such as 7 rows and 7 columns

[Code]....

View 2 Replies

Forms Data Controls :: Itemtemplate And Edittemplate - Row In Itemtemplate Will Disappear?

Jul 9, 2010

Now I have a datalist

I have done the itemtemplate and edittemplate,when I click on the button in itemtemplate, the edittemplate will show.But that row in itemtemplate will disappear.How can I keep that row in itemtemplate and ecotent in edittemplate both appear?

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved