c# - Bind to a hyperlinkfield in a gridview -


i have gridview pulls data xml file. 1 of columns of gridview hyperlinkfield. want bind url field contained in xml file column. think have right idea code below cant figure out how finish it. url datakey of gridview way.

protected void grdcontents_rowcreated(object sender, gridviewroweventargs e) {     ((hyperlinkfield)grdcontents.columns[1]).navigateurl =        } 

you can bind hyperlink on gridview_rowdatabound event this

    protected void gridview_rowdatabound(object sender, gridviewroweventargs e)         {             if (e.row.rowtype.equals(datacontrolrowtype.datarow))             {                 hyperlinkfield lnkhyper = (hyperlinkfield)e.row.findcontrol("hyperlinkfield1");                 lnkhyper.navigateurl="";             }         } 

try this.

or can bind url using databinder.eval @ time of binding source grid like

 <columns>        <asp:templatefield>                                                    <itemtemplate>              <asp:hyperlink runat="server"  navigateurl="<%# databinder.eval(container.dataitem, "url") %>"></asp:hyperlink>          </itemtemplate>         </asp:templatefield> </columns> 

you can use well, providing data source grid view.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -