C# Asp.net链接onrow命令不工作
下面给出了我的GridView id(Asp.net web应用程序) onRowCommand的我的方法C# Asp.net链接onrow命令不工作,c#,asp.net,gridview,webforms,C#,Asp.net,Gridview,Webforms,下面给出了我的GridView id(Asp.net web应用程序) onRowCommand的我的方法 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using FirstWebForm.business_objects; namespace FirstWebF
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FirstWebForm.business_objects;
namespace FirstWebForm
{
public partial class About : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
grid.DataSource = dataaccess.Instance.getAll();
grid.DataBind();
}
}
void ContactsGridView_RowCommand(Object sender, GridViewCommandEventArgs e)
{
}
}
}
但它遇到了一个错误
将
ContactsGridView\u row命令
方法更改为public
或protected
,如果要在代码隐藏中运行:
protected void ContactsGridView_RowCommand
或者将该方法放在页面上的脚本标记中,它将按原样工作
<script runat="server">
void ContactsGridView_RowCommand(Object sender, GridViewCommandEventArgs e)
{
...
}
</script>
void ContactsGridView_row命令(对象发送方,GridViewCommandEventArgs e)
{
...
}
protected void ContactsGridView_RowCommand
<script runat="server">
void ContactsGridView_RowCommand(Object sender, GridViewCommandEventArgs e)
{
...
}
</script>