如何在gridview中传递appsetting和databind?

时间:2012-01-12 01:41:38

标签: asp.net gridview

我想将一个appsetting值和sqldatasource值传递给gridview,以生成一个供用户点击的URL。

e.g。

  <appSettings>
    <add key="VirtualIP" value="http://192.168.1.1/wcm" /> 
  </appSettings>

  <asp:SqlDataSource ID="SqlDataSource1" runat="server"  meta:resourcekey="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:Test_ConnectionString %>"
            SelectCommand="select MeetingID, MeetName as MeetingName, MeetDate, Year(MeetDate) as MeetYear, Month(MeetDate) as MeetMth, MeetTime, convert(varchar, MeetDate, 111) + ' ' + convert(varchar, MeetTime, 108) AS ShowTime from Meeting where Status ='Recorded' order by MeetDate desc, Meettime desc ">

<asp:HyperLinkField DataNavigateUrlFields="MeetingID" DataNavigateUrlFormatString=""  DataTextField="MeetingID" DataTextFormatString="<img src='images/Audio_1.png'  border='0' />" />                   

此外,我想将MeetYear和MeetMth添加为URL

中的文件夹

如何在DataNavigateUrlFormatString中分配值?

<%appSettings: VirtualIP%> / MeetYear / MeetMth / {0}.wma

成为

http://192.168.1.1/wcm/2011/12/M11234.wma

的问候, 乔

2 个答案:

答案 0 :(得分:0)

试试<%# appSettings: VirtualIP%> / MeetYear / MeetMth / {0}.wma #遗失了。

答案 1 :(得分:0)

您必须使用$ expression

<%$ appSettings: VirtualIP %>