您的位置:首页 > 其它

GridView事件取值操作

2007-10-22 23:23 351 查看
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+"**");

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: