.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Gridview itemtemplate hyperlink

Posted By:      Posted Date: September 12, 2010    Points: 0   Category :ASP.Net
Can any help me I am facing a problem where I have to  set  Gridview itemtemplate hyperlink dynamically. Thanks

View Complete Post

More Related Resource Links

Textbox in ItemTemplate inside Gridview, unable to get the value


Hi. I have a itemtemplate inside a gridview.

<asp:TemplateField HeaderText="Enter OTP">
                            <asp:Label ID="Label2" runat="server"
                                style="font-family: Arial, Helvetica, sans-serif; font-size: x-small"
                                Text="PIN Num:"></asp:Label>
                            &nbsp;<asp:TextBox ID="txtPIN" runat="server" Height="21px" Width="100px"></asp:TextBox>

How To display image in GridView as hyperlink


Hello Everyone 

Could someone please help me with a little issue....

I was able to save the image in the database as binary....... but now i don´t know how to display it in the GridView as a hyperlink.

I´ve read something about ImageField..... I´d appreciate any help .


How to format an ItemTemplate value on a gridview control


I have the following in a GridView control:

<asp:TemplateField HeaderText="Count">
         <asp:Label id="lblicount" runat="server" Text='<%# Eval("icount") %>'>

Sometimes the value of this is 0.  I want to display nothing or a blank if the value is 0.  How do I do this?



Gridview hyperlink field

Hi I have a gridview that has two fields. Both fields are databound...but the one field is a hyperlink field which works fine...but I would like to add a Request.QueryString value to the the value retrieved from the database when setting the navigateurl property. Help would be much appreciated

Passing an ID from a hyperlink in a gridview

I have  gridview that lists a column of hyperlinked names.  A procedure is passed to get the data for the gridview.  I am also pulling an ID to use once the name is clicked.  Once clicked the ID is used in another procedure to populate a formview.  I am having a problem getting the ID to be associated to each hyperlink name in the column and figuring out how I am going to grab the ID from the asp:hyperlinkfield and then assigning it a variable to use elsewhere.  Any ideas?  Right now I trying to create a datarow with a new attribute.  Protected Sub grdvSearchlist_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles grdvSearchlist.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then Dim dvr As Data.DataRowView Dim dataItem As Data.DataRowView = e.Row.DataItem dvr = dataItem e.Row.Attributes.Add("argID", dvr(0).ToString()) End If End Sub  

Hyperlink in GridView

I have a GridView with the bounded Fields "ProductNumber" and "FilePath". The idea is to select a product from a row and to open the corresponding PDF from the file path in a new window via target=_blank, I have already searched via Google but I didn't find anything thats suitable. Something like this doens't works:<asp:TemplateField> <ItemTemplate> <asp:HyperLink ID="link" runat="server" datatextfield="ProductNumber" NavigateUrl="<%# FilePath %>">"</asp:HyperLink> </ItemTemplate> </asp:TemplateField>   I hope someone can help me. Thanks!  

convert column into hyperlink in gridview

hi how can i convert column in grid view into hyperlink  thanks

make onle specific cells in gridview as hyperlink

Dear all,   i have gridview and im displaying the employement history of employee. and im providing a hyperlink in empid to open employee page with update mode ..so that user can update the record. i have an issue here.only if the employeeresigned = "N" empid should be hyperlink, if its "Y" it should not be a hyperlink. How to do this.  <asp:TemplateField HeaderText="empid" SortExpression="empid">   <ItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" OnCommand ="empDetails_disp" Text='<%# Eval("empid") %>' CommandArgument='<%# Eval("empid", "{0}") %>' ForeColor="#0000C0"></asp:LinkButton> </ItemTemplate> </asp:TemplateField> am wondering how to do this 1) shall i replace all the linkbutton with label if the resignedstatus = "Y" - how to do this? 2) or shall i make the empid as boundfields instead of templatefields and write code on rowbound...with checkin that if resigned = "Y" then e.Row.Cells(0).BackColor = Drawing.Color.blue  e.Row.Cells(0).Attributes.Add("onclick", "empDetails_disp")  e.Row.Cells(0).Attributes.Add("class", "statusclass") ...... in this case i can use only javascript fu

About the itemtemplate within the gridview

Hi, guys  I meet an problem when I add 2 item templates into a gridview, one is a textbox and the other is a check box. The code is as following: <asp:GridView ID="gvTest" runat="server" ForeColor="#333333"                                 GridLines="Vertical" AllowPaging="True" DataKeyNames="mssolvetaskid"                                 onpageindexchanging="gvDisplay_PageIndexChanging"                                 onrowdatabound="gvDisplay_RowDataBound"                                AutoGenerateColumns="False" Width="100%">                     &nbs

Get non data item to the Gridview ItemTemplate Button

Can somebody suggest how to get the variable value to the hyperlink postbackurlHere the code that i have in Gridview<asp:TemplateField HeaderText="Process" ShowHeader="False">            <ItemTemplate>               <asp:Button ID="Button1" CssClass="btn" PostBackUrl='<%# String.Format("http://googlemaps.com?ID={0}&Name={1}&Address={2}", Eval("No"), Label2.text, Eval("Id"))%>'                runat="server" Text="Process" OnClick="LinkButton1_Click"   />             </ItemTemplate>            </asp:TemplateField>I have ID and Address parameter coming from the dataset/Datasource but not the Name parameter.Is there a way that I can pass the non databound item to the postBackUrl query string.

Hyperlink in GridView



           Here is my html

            <asp:HyperLink runat="server" ID="HyperLink1" NavigateUrl='<%# string.Format("Tiff.aspx?ID={0}", Eval("ID")) %>' Target="_blank" Text="View" ></asp:HyperLink>

I m getting an exception Like This..

DataBinding: 'System.Collections.Hashtable' does not contain a property with the name 'ID'.

Search an in a GridView



I would like to add a trigger to the UpdatePanel, the control is an ImageButton in a gridView like this:

                                <asp:TemplateField HeaderText="" ShowHeader="False">
                                    <%--<HeaderStyle Wrap="False" Width="25px" />--%>
                                    <ItemStyle HorizontalAlign="Left" Wrap="False" Width="25px" />
                                        <asp:ImageButton ID="imgDetalle" runat="server" CausesValidation="false" CommandName="VerDocumento"
                                            ImageUrl="~/imagesExterna/icoDetalle.gif" CommandArgument='<%# Eval("NOMBRE_DOCUMENTO") %>'
                                            ToolTip="Ver Documento" />
                                    <ItemStyle HorizontalAlign="center" Wrap="False" />

How can I add in codeBehind the trigger?? my code is this but

Clicking a GridView hyperlink to go to another WizardStep


Within a WizardStep in the AccountManagement.aspx page, I have the following Gridview:

                            <asp:GridView ID="GridViewUserAccounts" 
                                <AlternatingRowStyle BackColor="#EEEEEE" />
                                    <asp:HyperLinkField DataNavigateUrlFields="UserName" DataTextField="UserName" 
                                        HeaderText="User ID" />
                                    <asp:BoundField DataField="Email" HeaderText="Email" />

When a UserName HyperLinkField is clicked, I want to go to the another WizardStep.

With DataNavigateUrlFormatString="AccountManagement.aspx?user={0}, I think the page

change gridview itemtemplate cssclass from code-behind


I want to pgroammatically change the gridview ItemTemplate properties (mostly CSS Class)

<asp:GridView ID="gvSearchResults" GridLines="None" Width="700px" ShowHeader="False" AutoGenerateColumns="False" DataSourceID="XMLDS" runat="server"><Columns>
<ItemStyle CssClass="WHATEVER" />

So in the gridview rowdatabound event, I want to change the template based on the data for that specific row.

Apart from the data, how can I change the ItemTemplate CSS class for the current row via Code behind?

GridView -> ItemTemplate EventHandler setzen


Hi all,


i have a dynamically created GridView with a CheckBox by means of TemplateField.ItemTemplate. Now i want to add an EventHandler (CheckedChanged) on it. Is this possible?

          TemplateField tempField = new TemplateField();
          itemplateCheckBox chb = new itemplateCheckBox(dc_.ColumnName, GridView2);
          tempField.ItemTemplate = chb;
          tempField.HeaderText = dc_.ColumnName;


    public void InstantiateIn(Control container)
      CheckBox cb = new CheckBox();
      cb.DataBinding += new EventHandler(this.bindBooleans);
      cb.CheckedChanged += new EventHandler(this.checkBoxChanged);



How to compare asp.net Textbox value is equal to Gridview footer itemtemplate text box on button cli



I have one asp.net textbox and gridview footer template textbox on clicking the button, i need to check the textbox value is equal to gridview footer template textbox value are same....

my aspx page code:-

     <asp:TextBox ID="TextBox3" runat="server" TabIndex="1"></asp:TextBox>

<asp:TextBox id="we" runat="server"  Font-Size="10pt" Font-Names="Palatino Linotype" Font-Bold="True" ForeColor="#000000" Width="106px">

  <asp:Button ID="Button2" runat="server" BackColor="Transparent" BorderColor="Transparent"                      
                        Font-Size="10pt" ForeColor="#FFFFFF" Height="40px" OnClick="Button2_Click" Style="z-index: 101;
                        left: 113px; background-image: url(images/btn_5.png); position: absolute; top: 13px;
                        background-color: transparent" Text="Save" Width="94px" />

Show hyperlink on condition in Repeater ItemTemplate


Hi Everyone, being new to ASP.NET 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" >


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



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

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend