当前位置: 代码迷 >> ASP.NET >> 上下文找不到已经设定好的commandname解决办法
  详细解决方案

上下文找不到已经设定好的commandname解决办法

热度:8898   发布时间:2013-02-25 00:00:00.0
上下文找不到已经设定好的commandname
HTML code
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit" OnEditCommand="DataList1_EditCommand">确认接收</asp:LinkButton></td>                                </tr>

C# code
protected void DataList1_EditCommand(object source, DataListCommandEventArgs e)    {        if (e.CommandName==Edit)        {            bc.ExecSQL("UPDATE [file] SET examine = '已接收' WHERE fileID ='" + (int)DataList1.DataKeys[e.Item.ItemIndex] + "'");            DataList1.DataSource = bc.GetDataSet("select * from [file] where fileAccepter='" + Session["loginName"].ToString() + "' order by fileTime desc", "file");            DataList1.DataKeyField = "fileid";            DataList1.DataBind();        }


提示错误时上下文找不到Edit

------解决方案--------------------------------------------------------
要双引号 括起来吧
------解决方案--------------------------------------------------------
C# code
 if (e.CommandName=="Edit")
------解决方案--------------------------------------------------------
if (e.CommandName==Edit)
这都能编译过???????????
------解决方案--------------------------------------------------------
e.CommandName=="Edit"
------解决方案--------------------------------------------------------
就是嘛,那个是字符串呀,要用引号引起来
------解决方案--------------------------------------------------------
探讨
HTML code
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit" OnEditCommand="DataList1_EditCommand">确认接收</asp:LinkButton></td>
</tr>

C# code
protecte……
  相关解决方案