Repeater数据控件的用法总结(2)

public partial class index : System.Web.UI.Page { DataClassesDataContext dc = new DataClassesDataContext(); protected void Page_Load(object sender, EventArgs e) { var query = from c in dc.province select c; Repeater1.DataSource = query; Repeater1.DataBind(); } }

Cities.aspx页面中的代码:

<body> <form runat="server"> <div> <asp:GridView runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"> <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#EFF3FB" /> <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" /> <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" /> <EditRowStyle BackColor="#2461BF" /> <AlternatingRowStyle BackColor="White" /> </asp:GridView> </div> </form> </body>

Cities.aspx.cs页面中的代码:

public partial class Cities : System.Web.UI.Page { DataClassesDataContext dc = new DataClassesDataContext(); protected void Page_Load(object sender, EventArgs e) { int id =Convert.ToInt32(Request.QueryString["pro"].ToString()); var query = from c in dc.city where c.proID == id select c; GridView1.DataSource = query; GridView1.DataBind(); } }

然后运行index.aspx页面,通过单击超链接就跳转到了Cities.aspx,在该页面显示信息。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjyzsj.html