c# - Display DataGrid Column as Hyperlink Column depending on column value -
i have below datagrid works no problem
<asp:datagrid id="filebrowsergrid" runat="server" width="100%" pagesize="14" allowpaging="true" cellpadding="1" gridlines="none" bordercolor="#636e92" borderwidth="0px" autogeneratecolumns="false" onpageindexchanged="filebrowsergrid_pageindexchanged"> <alternatingitemstyle cssclass="mainbodytextalt"></alternatingitemstyle> <itemstyle cssclass="metadatabodytext"></itemstyle> <headerstyle cssclass="metadatabodytitle"></headerstyle> <footerstyle cssclass="blue"></footerstyle> <columns> <asp:boundcolumn datafield="loadedfileid" headertext="loaded file id" visible="false"></asp:boundcolumn> <asp:boundcolumn datafield="datasuppliercode" headertext="data supplier code"></asp:boundcolumn> <asp:boundcolumn datafield="datasuppliername" headertext="data supplier name"></asp:boundcolumn> <asp:boundcolumn datafield="filename" headertext="file name"></asp:boundcolumn> <asp:boundcolumn datafield="dateloaded" headertext="date loaded"></asp:boundcolumn> <asp:boundcolumn datafield="loadstatus" headertext="status"></asp:boundcolumn> </columns> <pagerstyle cssclass="gray"></pagerstyle> </asp:datagrid>
code behind:
dataset dataset = results.dataset; this.filebrowsergrid.datasource = dataset; this.filebrowsergrid.databind();
i want change status column display hyperlink errormessage.aspx id querystring value if value 'failed' stay normal text value if else.
ideally don't want make changes stored procedures
i've been looking @ rowdatabind haven't been able working.
any ideas? thank you!
i have solution aspx , not touch cs backend
you can predict render of template column. try suppose code status indicate failed "failed"
<asp:templatecolumn> <headertemplate> <b>status </b> </headertemplate> <itemtemplate> <asp:placeholder id="ok" runat="server" visible='<%# (eval("loadstatus").tostring()=="failed"?false:true) %>'><%----%> <asp:label id="label1" text='<%# eval("loadstatus") %>' runat="server" /> </asp:placeholder> <asp:placeholder id="ko" runat="server" visible='<%# (eval("loadstatus").tostring()=="failed"?true:false) %>'><%----%> <asp:hyperlink id="hyperlink1" runat="server" navigateurl='<%# string.format("dataloadererrormessage.aspx?id={0}",eval("loadedfileid"))%>'><%# eval("loadstatus") %></asp:hyperlink> </asp:placeholder> </itemtemplate> </asp:templatecolumn>
Comments
Post a Comment