난 그냥 누구를 위해이 관심 수있는 해결책을 발견 :
gv.RowDataBound += gv_RowDataBound;
gv.RowCommand += gv_RowCommand;
그런 다음 Linkbutton을 삽입하도록 RowDataBound를 정의하십시오.
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton butIgnorar = new LinkButton()
{
CommandName = "Ignorar",
ID = "butIgnorar",
Text = "Ignorar",
//optional: passes contents of cell 1 as parameter
CommandArgument = e.Row.Cells[1].Text.ToString()
};
//Optional: to include some javascript cofirmation on the action
butIgnorar.Attributes.Add("onClick", "javascript:return confirm('Are you sure you want to ignore?');");
TableCell tc = new TableCell();
tc.Controls.Add(butIgnorar);
e.Row.Cells.Add(tc);
}
}
마지막으로, 당신이 누군가에게 도움이 있다는 RowCommand
protected void gv_RowCommand(object sender, GridViewCommandEventArgs e)
{
string currentCommand = e.CommandName;
string parameter= e.CommandArgument.ToString();
if (currentCommand.Equals("Ignorar"))
{
yourMethodName(parameter);
}
}
희망에서 명령을 호출!
시험 사용해보기 : http://csharp.net-informations.com/datagridview/csharp-datagridview-button.htm – MrFox