尝试以下解决方案:
第 1 页,即您的列表页面:ASPX 代码:
<asp:GridView ID="GridView1" runat="server"
onrowdatabound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
代码背后:
protected void Page_Load(object sender, EventArgs e)
{
List<Data> lstData = new List<Data>();
for (int index = 0; index < 10; index++)
{
Data objData = new Data();
objData.EstimateID = index;
objData.VersionNo = "VersionNo" + index;
lstData.Add(objData);
}
GridView1.DataSource = lstData;
GridView1.DataBind();
}
public class Data
{
public int EstimateID { get; set; }
public string VersionNo { get; set; }
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HyperLink HyperLink1 = e.Row.FindControl("HyperLink1") as HyperLink;
HyperLink1.NavigateUrl = "Details.aspx?EstimateID=" + e.Row.Cells[1].Text + "&VersionNo=" + e.Row.Cells[2].Text;
}
}
第 2 页是您的详细信息页面:后面的代码:
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(Request.QueryString["EstimateID"].ToString());
Response.Write(Request.QueryString["VersionNo"].ToString());
}