C# 如何自动生成web表单?
使用Asp.net 4.0和visual studio 2010。 我有一个数据库和一个表,可以在其中插入新闻,我还制作了一个页面(WebForm)来向我的新闻表插入信息。我有另一个页面,其中有一个网格视图,这个网格视图显示新闻表中的所有内容,现在我想做的是,例如,当管理员想要插入新闻时,将创建一个页面,他插入的所有信息将显示在生成的或自动创建的页面中。 此外,在gridview中,在新闻表中显示的任何行旁边,我希望显示一个超链接,该超链接将页面重定向到包含所选行信息的页面(我指的是我已经生成的页面)。 有人能帮忙吗 以下是我的gridview代码:C# 如何自动生成web表单?,c#,html,asp.net,gridview,webforms,C#,Html,Asp.net,Gridview,Webforms,使用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>
: نام
: نام خانوادگی
: رشته تدریس
: نام لاتین
: نام خانوادگی با لاتین
: رشته تدریس به لاتین
没有要显示的数据
基于详细信息页面上的新闻id绑定数据后。在每一行单击可以获得不同的新闻id。表示在其他页面中显示新闻详细信息。对吗?不,我的意思是当有人插入一个新闻页面时,会自动创建一个页面,并在创建的页面中显示插入的数据…意思是当您单击网格视图行重定向其他页面并在该页面上显示所选行数据时?因此无需生成动态页面。您可以使用查询字符串概念在单个页面中执行此操作。我应该如何执行此操作?好的,我已经创建了一个webform,并在页面加载中键入了以下代码:
int newsid=Convert.ToInt32(Request.QueryString[“newsid]”);Label1.Text=newsid.ToString()
但我得到了这个错误:输入字符串的格式不正确。在我的gridview项目模板中,我在新闻标题中放置了一个超链接和超链接的文本,当你单击它时,它会将你重定向到NewsDetail.aspx页面。这是我的代码:``我的问题已解决,谢谢
<a href='NewsDetail.aspx?newsId=<%# Eval("NewsId") %>'> <asp:Image ID="Image2" runat="server" Height="180px" ImageUrl='<%# Eval("IMG") %>' Width="193px" BorderColor="#CCCCCC" BorderStyle="Solid" /></a>
int newsid= convert.ToInt32(Request.Querystring["newsId"]);