网站的一个基本功能,即在一个页面内加载不同的内容,如某一页的
URL:****.aspx?PostID={0}
如.net 2.0 GridView中的HyperLinkField就有
DataNavigateUrlFormatString="ShowNews.aspx?PostID={0}"的属性
页面内容的加载是怎样实现的,能不能给举个例子?
URL:****.aspx?PostID={0}
如.net 2.0 GridView中的HyperLinkField就有
DataNavigateUrlFormatString="ShowNews.aspx?PostID={0}"的属性
页面内容的加载是怎样实现的,能不能给举个例子?
if
page A DataNavigateUrlFormatString="ShowNews.aspx?id=1"
page B get 内容 where id = 1if
page A DataNavigateUrlFormatString="ShowNews.aspx?id=2"
page B get 内容 where id = 2
DataNavigateUrlFormatString或者NavigateUrl这个来使用
如果DataNavigateUrlFields中有多个字段,在需要第一个字段时使用{0}, 第二个字段使用{1},以此类推.
DataKeyNames="VoteId" DataSourceID="sdsVote" ForeColor="#333333" GridLines="None" Width="778px" AllowPaging="True" PageSize="20">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:TemplateField HeaderText="投票者ID">
<ItemTemplate>
<a href='voteResult.aspx?VoteId=<%# DataBinder.Eval(Container.DataItem,"VoteId") %>' target="_blank"><%# DataBinder.Eval(Container.DataItem,"VoteId") %></a>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="UserInfo" HeaderText="投票者信息" SortExpression="UserInfo" />
</Columns>
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="CornflowerBlue" ForeColor="White" HorizontalAlign="Left" Font-Size="12px" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:SqlDataSource ID="sdsVote" runat="server" ConnectionString="<%$ ConnectionStrings:fbcon %>"
SelectCommand="SELECT [VoteId], [Need], [Channel], [ChannelOther], [Look], [Attention], [AttentionOther], [Accept], [Know], [KnowOther], [UserInfo] FROM [UserVote] ORDER BY [VoteId] Desc">
</asp:SqlDataSource>
当将鼠标放在GridView上的HyperLinkField上时会显示URL:ShowNews.aspx?{0}({1},是数据库中的news_id)等,关键是怎样在ShowNews.aspx中显示相应的数据库中的对应内容,
DataNavigateUrlFields = "news_id,等" DataNavigateUrlFormatString="ShowNews.aspx?news_id={0}&other={1}" />
GridView DataSource
绑定了吗?
==
绑定了,在ShowNews.aspx页面内怎么显示相应的值?
就等于
DataNavigateUrlFormatString="ShowNews.aspx?news_id=<%# Eval("news_id")%>&other=<%# Eval("等")%>"