实现点击两个按钮,跳转到同一个界面,HyperLink显示不同的东西,主要代码段如下
前台代码:
<asp:TemplateField HeaderText="操作"> <ItemTemplate> <asp:HyperLink ID="HlOperate" runat="server"></asp:HyperLink> </ItemTemplate> <HeaderStyle HorizontalAlign="Center" /> </asp:TemplateField>
后台代码:flag为两个按钮传来的数据
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { HyperLink hlOperate = (HyperLink)e.Row.FindControl("HlOperate"); String flag = Request.Params["flag"]; if (flag == "0") { hlOperate.Text = "A"; hlOperate.NavigateUrl = "~/GetFyqd.aspx?HEALTH_EVN_ID=" + DataBinder.Eval(e.Row.DataItem, "HEALTH_EVN_ID") + "&VISIT_ORGANIZATION_CODE=" + DataBinder.Eval(e.Row.DataItem, "VISIT_ORGANIZATION_CODE"); } else if (flag == "1") { hlOperate.Text = "B"; hlOperate.NavigateUrl = ""; } } }
时间: 2024-10-02 21:19:58