下面是我的代码:点击Button的时候什么反应都没有!我的原意是点Button的时候就更新数据库的内容,劳烦帮忙看看是什么原因。
HTML:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" EnableEventValidation="false" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table style="width: 728px">
            <tr>
                <td colspan="3">
                    -=文件接收=-</td>
                <td colspan="1">
                </td>
            </tr>
            <tr>
                <td style="width: 263px; height: 23px;">
                </td>
                <td colspan="2" style="width: 238px; height: 23px;">
                    <asp:RadioButton ID="显示未接收" runat="server" AutoPostBack ="true" Checked ="true"  GroupName ="aa" Text="显示未接收"   />
                    </td>
                <td colspan="1" style="width: 238px; height: 23px">
                    <asp:RadioButton ID="显示已接收" runat="server"  AutoPostBack ="true" GroupName ="aa" Text="显示已接收" /></td>
            </tr>
            <tr>
                <td colspan="4">
                    <asp:DataList ID="DataList1" runat="server" OnItemCommand ="DataList1_ItemCommand"  >
                        <ItemTemplate>
                            <table style="width: 592px">
                                <tr>
                                    <td style="width: 112px">
                                        文件标题:</td>
                                    <td colspan="2">
                                    <%#DataBinder .Eval (Container .DataItem ,"filetitle") %>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 112px">
                                        来自:</td>
                                    <td style="width: 212px">
                                    <%#DataBinder.Eval(Container.DataItem, "filesender")%>
                                    </td>
                                    <td>
                                        接收状态:<%#DataBinder.Eval(Container.DataItem, "examine")%> 
                                        <asp:Button ID="确认接收" runat="server" Text="确认接收"  CommandName  ="opear" /></td>
                                </tr>
                                <tr>
                                    <td style="width: 112px; height: 77px">
                                        文件内容:</td>
                                    <td colspan="2" style="height: 77px">
                                        <%#DataBinder.Eval(Container.DataItem, "filecontent")%> 
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 112px">
                                        附件:</td>
                                    <td style="width: 212px">
                                        <%#DataBinder.Eval(Container.DataItem, "filename")%> <a href="<%#DataBinder.Eval(Container.DataItem, "path")%>">下载</a>
                                        </td>
                                    <td>
                                        时间:<%#DataBinder.Eval(Container.DataItem, "filetime")%></td>
                                </tr>
                            </table>
                        </ItemTemplate>
                    </asp:DataList></td>
            </tr>
        </table>
    
    </div>
    </form>
</body>
</html>
. cs中的代码:
baseclass bc=new baseclass() ;
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        Response.Write(bc.messagebox("fffff"));
        if (e.CommandArgument != null)
        {
            int intID = Convert.ToInt32(e.CommandArgument);            bc.execsql("update [file] set examine='已接收' where fileid='" + intID.ToString() + "'");
            DataList1.DataSource = bc.getdataset("select * from [file] where examine='已接收' order by filetime desc", "file");
            DataList1.DataKeyField = "fileid";
            DataList1.DataBind();
        }
    }

解决方案 »

  1.   

    是不是页面刷新了?在load函数中添加if(!IsPostBack){
    //你的代码
    }试一下
      

  2.   

    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                DataList1 .DataSource =bc.getdataset ("select * from [file] where examine='已接收' order by filetime desc","file");
                DataList1.DataKeyField = "fileid";
                DataList1.DataBind();        }
            if (显示未接收.Checked)
            {
                DataList1.DataSource = bc.getdataset("select * from [file] where examine='未接收' order by filetime desc", "file");
                DataList1.DataKeyField = "fileid";
                DataList1.DataBind();
            }
            if (显示已接收.Checked)
            {
                DataList1.DataSource = bc.getdataset("select * from [file] where examine='已接收' order by filetime desc", "file");
                DataList1.DataKeyField = "fileid";
                DataList1.DataBind();
            }
        }
        
    我的LOAD代码中有的,还是不行啊!!!!!!!!!!
      

  3.   

    你的bc.execsql测试过了吗?把button换成linkButton试一下。