1.通过设置建DataKey
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
    string Id = this.GridView1.SelectedDataKey.Value.ToString();
    Response.Redirect("UpdateCurriculum.aspx?CId=" + Id.ToString());
}
2.GridView中CommandName的使用
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
     if (e.Row.RowType == DataControlRowType.DataRow)
     {

        LinkButton LinkButton1 = (LinkButton)e.Row.FindControl("LinkButton1");
        
LinkButton1.CommandArgument = e.Row.RowIndex.ToString();
        
LinkButton LinkButton2 = (LinkButton)e.Row.FindControl("LinkButton2");
        
LinkButton2.CommandArgument = e.Row.RowIndex.ToString();
    
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
     if (e.CommandName == "OpeanteName1")
     {
        
int index = Convert.ToInt32(e.CommandArgument);
        
GridViewRow row = GridView1.Rows[index];
        
Response.Write(index);
}
     if (e.CommandName == "OpeanteName1")
     {
        
int index = Convert.ToInt32(e.CommandArgument);
        
GridViewRow row = GridView1.Rows[index];
        
Response.Write(index+"**");
    }

}

相关文章:

  • 2021-05-21
  • 2022-12-23
  • 2021-05-21
  • 2021-08-19
  • 2022-12-23
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-03-04
  • 2021-11-30
  • 2022-02-20
  • 2021-10-13
  • 2021-08-10
  • 2022-12-23
  • 2021-12-19
相关资源
相似解决方案