日期:2014-05-17 浏览次数:20392 次
<asp:HyperLink ID= "HyperLink1" NavigateUrl='<%#"/xxnrfile/niankaoyanxxnr2.aspx?tableid="+<%=i.ToString()%>%>' runat="server"> <%#DataBinder.Eval(Container.DataItem,"title")%></asp:HyperLink>
<%=i.ToString()%>
<%@ Page Language="C#" AutoEventWireup="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> public int i = 100; protected void Page_Load(object sender, EventArgs e) { System.Data.DataTable dataTable1 = new System.Data.DataTable("BlogUser"); dataTable1.Columns.Add(new System.Data.DataColumn("UserId", typeof(System.Int32))); dataTable1.Columns.Add(new System.Data.DataColumn("Title", typeof(System.String))); for (int i = 0; i < 8; i++) { dataTable1.Rows.Add(new Object[] { i, "【孟子E章】" + i.ToString() }); } DataList1.DataSource = dataTable1; DataList1.DataBind(); } protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { HyperLink HyperLink1 = e.Item.FindControl("HyperLink1") as HyperLink; HyperLink1.NavigateUrl += i.ToString(); //多复杂的都能在这里处理了@@@@@ } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>无标题页</title> </head> <body> <form id="form1" runat="server"> <asp:DataList ID="DataList1" runat="server" OnItemDataBound="DataList1_ItemDataBound"> <ItemTemplate> <div> <asp:HyperLink ID="HyperLink1" NavigateUrl="/xxnrfile/niankaoyanxxnr2.aspx?tableid=" runat="server"><%#Eval("Title")%></asp:HyperLink> </div> </ItemTemplate> </asp:DataList> </form> </body> </html>
------解决方案--------------------
函数写在后天文件里面
------解决方案--------------------