【发布时间】:2016-01-30 14:54:25
【问题描述】:
使用 Asp.net 4.0 和 Visual Studio 2010。 我有一个数据库和一个在其中插入新闻的表格,并且我制作了一个页面(WebForm)来将信息插入我的新闻表格。我有另一个页面,其中有一个网格视图,这个网格视图显示新闻表中的所有内容,现在我要做的是例如当管理员想要插入新闻时,然后将创建一个页面并且所有他插入的信息将显示在生成或自动创建的页面中。 同样在从新闻表显示的任何行旁边的网格视图中,我想显示一个超链接,该超链接会将页面重定向到具有所选行信息的页面(在我已经生成的页面中,我的意思是)。 有人可以帮忙吗?!
这是我的 gridview 代码:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" Width="187px" CellPadding="4"
EnableTheming="True" ForeColor="#333333" HorizontalAlign="Center" PageIndex="1"
PageSize="5" ShowFooter="True"
>
<AlternatingRowStyle BorderColor="White" BackColor="White" />
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<div style="background-color: #FFFFFF">
</div>
</HeaderTemplate>
<ItemTemplate>
<div class="gridview"
style="border-color: #FFFFFF; border-style: none; width: 924px; height: 141px; text-align: center; text-decoration: none;"
align="right" dir="ltr">
<table class="auto-style1">
<tr>
<td class="style2">
<table class="auto-style1">
<tr>
<td>
</td>
<td style="text-align: left">
<asp:Image ID="Image2" runat="server" Height="180px"
ImageUrl='<%# Eval("IMG") %>' Width="193px" BorderColor="#CCCCCC"
BorderStyle="Solid" />
</td>
<td>
</td>
</tr>
</table>
</td>
<td>
<table class="auto-style1">
<tr>
<td class="style9">
<asp:Label ID="Label3" runat="server" Font-Names="Microsoft Uighur"
Font-Size="X-Large" Text='<%# Eval("Fname") %>'></asp:Label>
</td>
<td class="style3">
: نام</td>
</tr>
<tr>
<td class="style9">
<asp:Label ID="Label4" runat="server" Font-Names="Microsoft Uighur"
Font-Size="X-Large" Text='<%# Eval("Lname") %>'></asp:Label>
</td>
<td class="style3">
: نام خانوادگی</td>
</tr>
<tr>
<td class="style9">
<asp:Label ID="Label5" runat="server" Font-Names="Microsoft Uighur"
Font-Size="X-Large" Text='<%# Eval("Major") %>'></asp:Label>
</td>
<td class="style8">
: رشته تدریس</td>
</tr>
<tr>
<td class="style9">
<asp:Label ID="Label6" runat="server" Font-Names="Microsoft Uighur"
Font-Size="X-Large" Text='<%# Eval("EnFname") %>'></asp:Label>
</td>
<td class="style3">
: نام لاتین</td>
</tr>
<tr>
<td class="style5">
<asp:Label ID="Label7" runat="server" Font-Names="Microsoft Uighur"
Font-Size="X-Large" Text='<%# Eval("EnLname") %>'></asp:Label>
</td>
<td class="style3">
: نام خانوادگی با لاتین</td>
</tr>
<tr>
<td class="style9">
<asp:Label ID="Label8" runat="server" Font-Names="Microsoft Uighur"
Font-Size="X-Large" Text='<%# Eval("EnMajor") %>'></asp:Label>
</td>
<td class="style3">
: رشته تدریس به لاتین</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<br />
<br />
<br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EditRowStyle BackColor="#2461BF" />
<EmptyDataRowStyle BackColor="White" />
<EmptyDataTemplate>
<div style="height: 115px; width: 914px">
No data to display<br />
<br />
<br />
<br />
</div>
</EmptyDataTemplate>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<PagerTemplate>
<div style="height: 131px; ">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Fname") %>'></asp:Label>
<br />
<br />
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Lname") %>'></asp:Label>
<br />
<br />
</div>
<br />
<br />
<br />
<br />
</PagerTemplate>
<RowStyle BorderColor="White" BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
【问题讨论】:
-
表示在其他页面显示新闻详情。对吗?
-
不,我的意思是当有人插入新闻时,会自动创建一个页面并将插入的数据显示在创建的页面中......
-
意思是当你点击grid view row来重定向其他页面并在这个页面上显示选中的行数据?
-
所以不需要生成动态页面。您可以使用查询字符串概念在单页中执行。
-
那我该怎么做呢?
标签: c# html asp.net gridview webforms