asp:HyperLink 控件不同数据 跳转不同的页面

<asp:HyperLink ID="hlDetail" CssClass="details" runat="server" OnPreRender="HyperLink_DataBinding"
Text='<%# Eval("Id") %>' Target="_blank"></asp:HyperLink>

 

重点在 OnPreRender 事件

protected void HyperLink_DataBinding(object sender, EventArgs e)
{
HyperLink HyperLink = sender as HyperLink;
int bid = 0;
if (int.TryParse(HyperLink.Text, out bid))
{
//HyperLink.Attributes.Add("onclick", "checkOrder(this,'" + bid + "','" + AccountInfo.EmpId + "');");
HyperLink.Text = "详情";
Examine_OrderPool order = OrderList.SingleOrDefault(o => o.Id == bid);
int flowtype = Convert.ToInt32(order.FlowType);
switch (flowtype)
{

case (int)FlowType.RapidPlus:
HyperLink.NavigateUrl = "../ExamineIMP/ExamineDetail.aspx?Bid=" + bid;
break;

case (int)FlowType.BuyVehiclePho:
HyperLink.NavigateUrl = "../ExamineIMP/VMortgageExamineDetail.aspx?Bid=" + bid;
break;

}
}
}

posted @ 2017-12-12 10:46  我的女人是捡的  阅读(884)  评论(0编辑  收藏  举报