datalist 的 DataList_ItemCommand 事件中 用 CommandName 获取的点击 操作的代码 执行不了!         protected void LittleScripDataList_ItemCommand(object source, DataListCommandEventArgs e)
    {        if(e.CommandName=="xinfeng")
        {
         string sql = "Update MylittleScrip Set IfSee=1 where Id=" + int.Parse(e.CommandArgument.ToString());
          
           IList<MylittleScrip> li= MylittleScripManager.UPdateMylittleScripsIfSeeBySql(sql);           BindScrip();
        }
}请有经验的人!指导一下!谢谢~~~~很急!!!拜托大家了!

解决方案 »

  1.   

    看你的前台html另有没有操作过这个按纽?
      

  2.   

    你dataList里的控件的CommandName设置了吗
      

  3.   

    没有操作过!  <asp:DataList ID="LittleScripDataList" runat="server" Width="625px" OnItemCommand="LittleScripDataList_ItemCommand" OnItemDataBound="LittleScripDataList_ItemDataBound">
                        <ItemTemplate>
                            &nbsp;<asp:ImageButton ID="EverIfSee" runat="server" CommandArgument='<%# Eval("Id") %>' CommandName="xinfeng" />
                            <asp:Label ID="IfSeeLabel" runat="server" Text='<%# Eval("IfSee") %>'></asp:Label>
                            <asp:Label ID="IdLabel" runat="server" Text='<%# Eval("Id") %>' Visible="False"></asp:Label>Main:
                            <asp:Label ID="MainLabel" runat="server" Text='<%# Eval("Main") %>'></asp:Label>&nbsp;
                            <asp:Label ID="Label1" runat="server" ForeColor="Blue" Text="来至于:"></asp:Label>&nbsp;
                            <asp:Label ID="SendManLabel" runat="server" Text='<%# Eval("SendMan") %>'></asp:Label>
                            接收者:
                            <asp:Label ID="GetManLabel" runat="server" Text='<%# Eval("GetMan") %>'></asp:Label><br />
                            内容:
                            <asp:Label ID="NoteLabel" runat="server" Text='<%# Eval("Note") %>'></asp:Label>
                            <asp:Label ID="SStateLabel" runat="server" Text='<%# Eval("SState") %>' Visible="False"></asp:Label><br />
                            发送时间:
                            <asp:Label ID="PostTimeLabel" runat="server" Text='<%# Eval("PostTime") %>'></asp:Label>&nbsp;<br />
                            <div style="width: 670px; height: 21px; text-align: right">
                                <asp:LinkButton ID="deleteIt" runat="server" CommandName="DeleteThisOne" OnClientClick="return confirm('确认要删除此张纸条吗?')" CommandArgument='<%# Eval("Id") %>'>删除</asp:LinkButton>
                                |
                                <asp:LinkButton ID="ToBack" runat="server" CommandName="GiveBack" OnClientClick="javaScript:showEdit();" CommandArgument='<%# Eval("Id") %>'>回复</asp:LinkButton></div>
                        </ItemTemplate>
      

  4.   

    LittleScripDataList_ItemCommand事件关联
    有写么?
      

  5.   

    哦,看到了,EverIfSee的src没看到赋值?
      

  6.   

    不会是事件丢失吧,建议把LittleScripDataList_ItemCommand删掉,重新添一遍试试
      

  7.   

    我加了!
    <asp:ImageButton ID="EverIfSee" runat="server" CommandArgument='<%# Eval("Id") %>' CommandName="xinfeng" ImageUrl="~/envelope/guan.jpg" />还是不好使! 删除也不好使!
      

  8.   

    我也重新添加了!还是不好使!  还有出现这问题前!出现过一个像自动安装进程的东西!很快就加载完了!注:是软件内的!绝不是其他的!还有!
        protected void LittleScripDataList_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            //绑定小纸条是否看过!
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                UserInfo us = Session["user"] as UserInfo;
                string sql = "select * from MylittleScrip where GetMan='" + us.NickName + "'";
                IList<MylittleScrip> mlss = MylittleScripManager.GetMylittleScripsBySql(sql);            foreach (MylittleScrip mm in mlss)
                {
                    ImageButton iim = e.Item.FindControl("EverIfSee") as ImageButton;
                    if (mm.IfSee == 0)
                    {
                        iim.ImageUrl = "~/envelope/guan.jpg";
                    }
                    if (mm.IfSee == 1)
                    {
                       iim.ImageUrl = "~/envelope/kai.jpg";
                    }
      

  9.   

    iim后面还有没有操作的代码?如onclick之类的.
      

  10.   


    哥们,我怎么没看到你在前台写“CommandName="xinfeng"” 呢,你不写,后台咋能找到呢
      

  11.   

    哥们,我怎么没看到你在前台写“CommandName="xinfeng"” 呢,你不写,后台咋能找到呢
    ==>
    lz有写的./
      

  12.   

    楼主是不是把页面的ViewState关闭了
      

  13.   

    ViewState关闭 怎么关,我都不知道!请问在哪啊!我看看!
      

  14.   

    现在基本确定你的问题出现在LittleScripDataList_ItemDataBound事件中了,贴代码看看
      

  15.   

        protected void LittleScripDataList_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            //绑定小纸条是否看过!
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                UserInfo us = Session["user"] as UserInfo;
                string sql = "select * from MylittleScrip where GetMan='" + us.NickName + "'";
                IList<MylittleScrip> mlss = MylittleScripManager.GetMylittleScripsBySql(sql);            foreach (MylittleScrip mm in mlss)
                {
                    ImageButton iim = e.Item.FindControl("EverIfSee") as ImageButton;
                    if (mm.IfSee == 0)
                    {
                        iim.ImageUrl = "~/envelope/guan.jpg";
                    }
                    if (mm.IfSee == 1)
                    {
                        iim.ImageUrl = "~/envelope/kai.jpg";
                    }
                }        }
        }这段代码我注掉,也不好使!!!
      

  16.   

    protected void LittleScripDataList_ItemDataBound(object sender, DataListItemEventArgs e)
    我觉得应该是object sender
      

  17.   

    这段有问题,还遍历?你遍历什么呀?红色部分放里面准备干什么呀:foreach (MylittleScrip mm in mlss)
      {
      ImageButton iim = e.Item.FindControl("EverIfSee") as ImageButton;
      if (mm.IfSee == 0)
      {
      iim.ImageUrl = "~/envelope/guan.jpg";
      }
      if (mm.IfSee == 1)
      {
      iim.ImageUrl = "~/envelope/kai.jpg";
      }
      

  18.   

    这段有问题,还遍历?你遍历什么呀?红色部分放里面准备干什么呀:foreach (MylittleScrip mm in mlss)
      {
      ImageButton iim = e.Item.FindControl("EverIfSee") as ImageButton;
      if (mm.IfSee == 0)
      {
      iim.ImageUrl = "~/envelope/guan.jpg";
      }
      if (mm.IfSee == 1)
      {
      iim.ImageUrl = "~/envelope/kai.jpg";
      }
      

  19.   

    这段有问题,还遍历?你遍历什么呀?红色部分放里面准备干什么呀:foreach (MylittleScrip mm in mlss)
      {
      ImageButton iim = e.Item.FindControl("EverIfSee") as ImageButton;
      if (mm.IfSee == 0)
      {
      iim.ImageUrl = "~/envelope/guan.jpg";
      }
      if (mm.IfSee == 1)
      {
      iim.ImageUrl = "~/envelope/kai.jpg";
      }