若只是简单的一个选择列edit就正常了。怎么做到增加一个datarowbound事件edit有效
protected void gviewEmployee_SelectedIndexChanged(object sender, EventArgs e)
{
Label txtMsg = new Label();
switch (gviewEmployees.Rows[gviewEmployees.SelectedIndex].RowState)
{
case DataControlRowState.Selected:
txtMsg.Text = "你选择奇数行,行状态为" + gviewEmployees.Rows[gviewEmployees.SelectedIndex].RowState + ": " +
gviewEmployees.Rows[gviewEmployees.SelectedIndex].Cells[3].Text;
break;
case DataControlRowState.Alternate|DataControlRowState.Selected:
txtMsg.Text="你选择偶数行,行状态为"+gviewEmployees.Rows[gviewEmployees.SelectedIndex].RowState+": "+gviewEmployees.Rows[gviewEmployees.SelectedIndex].Cells[3].Text;
break;
}
Page.Controls.Add(txtMsg);
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
PostBackOptions myPostBackOptions = new PostBackOptions(this);
myPostBackOptions.AutoPostBack = false;
myPostBackOptions.RequiresJavaScriptProtocol = true;
myPostBackOptions.PerformValidation = false;
String evt = Page.ClientScript.GetPostBackClientHyperlink(sender as System.Web.UI.WebControls.GridView, "Select$" + e.Row.RowIndex.ToString());
if (e.Row.RowType == DataControlRowType.DataRow)
{
//单击事件
e.Row.Attributes.Add("onclick", evt);
e.Row.Attributes["style"] = "Cursor:hand";
}
}