GridView 列中的超链接,带页面间的值传递方法。格式化类的。

来源:互联网 发布:棋牌类游戏算法 编辑:程序博客网 时间:2024/04/28 21:09
                                                      " + DataBinder.Eval(Container.DataItem,"teacherRealName").ToString() + ""%>' runat="server">                                                                                                                  (" + DataBinder.Eval(Container.DataItem,"minNum").ToString() + "~" + DataBinder.Eval(Container.DataItem,"maxNum").ToString() + ")-" + DataBinder.Eval(Container.DataItem,"curNum").ToString()+  "") %>' runat="server">                                                 

页面级别:
  <asp:HyperLinkField HeaderText="修改" DataNavigateUrlFields="courseId"  Text="修改"  >
                             <ItemStyle HorizontalAlign="Center" />
                        </asp:HyperLinkField>

数据GridView绑定处理链接传递值:
 protected void GridViewList_RowDataBound(object sender, GridViewRowEventArgs e)
{
  e.Row.Cells[8].Attributes.Add("onclick", "javascript: return confirm('确定要删除吗?');");
                /// <summary>              
                /// 格式化传值
                /// </summary>
                ///


                courseId = Convert.ToInt32(e.Row.Cells[9].Text.ToString());
                HyperLink hy = (HyperLink)e.Row.Cells[7].Controls[0];
                hy.NavigateUrl = string.Format("Edit.aspx?operate=2&PlanId={0}&Type={1}&Level={2}&Unit={3}&courseId={4}", new object[] {
                     currentPlanId
                    ,currentType
                    ,currentLevel
                    ,currentUnit
                    ,courseId
                  
                    });
}

还有一种: