*.aspx 中<%# DataBinder.Eval(Container.DataItem, "序号")%>得不到值
 *.aspx.cs中private void MyList_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) 事件不执行,请问是怎么回事?
上面问题是在加入分页后才出现的

解决方案 »

  1.   

    <%@ Page language="c#" Codebehind="manage_r.aspx.cs" AutoEventWireup="false" Inherits="rule_of_law.manage_r" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>manage_rol</title>
    <META http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <asp:label id="Label1" style="Z-INDEX: 119; LEFT: 40px; POSITION: absolute; TOP: 56px" runat="server"
    Height="16px" Width="72px">发布者:</asp:label><asp:button id="Button3" style="Z-INDEX: 123; LEFT: 152px; POSITION: absolute; TOP: 232px" runat="server"
    Height="24px" Width="88px" Text="取消所选"></asp:button><asp:button id="Button2" style="Z-INDEX: 122; LEFT: 240px; POSITION: absolute; TOP: 232px" runat="server"
    Height="24px" Width="88px" Text="删除所选"></asp:button><asp:textbox id="TextBox1" style="Z-INDEX: 101; LEFT: 104px; POSITION: absolute; TOP: 56px" runat="server"
    Height="16px" Width="104px"></asp:textbox><asp:label id="Label2" style="Z-INDEX: 102; LEFT: 224px; POSITION: absolute; TOP: 56px" runat="server"
    Height="8px" Width="48px">名称:</asp:label><asp:textbox id="TextBox2" style="Z-INDEX: 103; LEFT: 272px; POSITION: absolute; TOP: 56px" runat="server"
    Height="16px" Width="224px"></asp:textbox><asp:label id="Label3" style="Z-INDEX: 104; LEFT: 512px; POSITION: absolute; TOP: 56px" runat="server"
    Height="16px" Width="80px">是否发布:</asp:label><asp:dropdownlist id="DropDownList1" style="Z-INDEX: 105; LEFT: 608px; POSITION: absolute; TOP: 56px"
    runat="server" Height="32px" Width="112px"></asp:dropdownlist><asp:label id="Label4" style="Z-INDEX: 106; LEFT: 32px; POSITION: absolute; TOP: 104px" runat="server"
    Height="24px" Width="96px">发布时间段:</asp:label><asp:dropdownlist id="DropDownList2" style="Z-INDEX: 107; LEFT: 128px; POSITION: absolute; TOP: 104px"
    runat="server" Height="32px" Width="56px">
    <asp:ListItem Value="2005">2005</asp:ListItem>
    </asp:dropdownlist><asp:label id="Label5" style="Z-INDEX: 108; LEFT: 192px; POSITION: absolute; TOP: 104px" runat="server"
    Height="24px" Width="24px">年</asp:label><asp:dropdownlist id="DropDownList3" style="Z-INDEX: 109; LEFT: 224px; POSITION: absolute; TOP: 104px"
    runat="server" Height="24px" Width="40px">
    <asp:ListItem Value="11">11</asp:ListItem>
    </asp:dropdownlist><asp:label id="Label6" style="Z-INDEX: 110; LEFT: 272px; POSITION: absolute; TOP: 104px" runat="server"
    Height="24px" Width="24px">月</asp:label><asp:dropdownlist id="DropDownList4" style="Z-INDEX: 111; LEFT: 296px; POSITION: absolute; TOP: 104px"
    runat="server" Height="24px" Width="40px">
    <asp:ListItem Value="11">11</asp:ListItem>
    </asp:dropdownlist><asp:label id="Label7" style="Z-INDEX: 112; LEFT: 344px; POSITION: absolute; TOP: 104px" runat="server"
    Height="24px" Width="120px">日 ===>到<                       ===</asp:label><asp:dropdownlist id="DropDownList5" style="Z-INDEX: 113; LEFT: 472px; POSITION: absolute; TOP: 104px"
    runat="server" Height="24px" Width="72px">
    <asp:ListItem Value="2005">2005</asp:ListItem>
    </asp:dropdownlist><asp:label id="Label8" style="Z-INDEX: 114; LEFT: 552px; POSITION: absolute; TOP: 104px" runat="server"
    Height="24px" Width="24px">年</asp:label><asp:dropdownlist id="DropDownList6" style="Z-INDEX: 115; LEFT: 576px; POSITION: absolute; TOP: 104px"
    runat="server" Height="24px" Width="48px">
    <asp:ListItem Value="11">11</asp:ListItem>
    </asp:dropdownlist><asp:label id="Label9" style="Z-INDEX: 116; LEFT: 632px; POSITION: absolute; TOP: 104px" runat="server"
    Height="24px" Width="24px">月</asp:label><asp:dropdownlist id="DropDownList7" style="Z-INDEX: 117; LEFT: 656px; POSITION: absolute; TOP: 104px"
    runat="server" Height="24px" Width="40px">
    <asp:ListItem Value="11">11</asp:ListItem>
    </asp:dropdownlist><asp:label id="Label10" style="Z-INDEX: 118; LEFT: 696px; POSITION: absolute; TOP: 104px" runat="server"
    Height="24px" Width="16px">日</asp:label><asp:datagrid id="MyList" style="Z-INDEX: 120; LEFT: 64px; POSITION: absolute; TOP: 144px" runat="server"
    Width="656px" AllowPaging="True" PageSize="2" AutoGenerateColumns="False">
    <SelectedItemStyle Font-Size="9pt" Font-Names="宋体"></SelectedItemStyle>
    <EditItemStyle Font-Size="9pt" Font-Names="宋体" Font-Bold="True" ForeColor="Red" BackColor="Info"></EditItemStyle>
    <AlternatingItemStyle Font-Size="9pt" Font-Names="宋体" ForeColor="ControlText" BackColor="White"></AlternatingItemStyle>
    <ItemStyle Font-Size="9pt" Font-Names="宋体" ForeColor="ControlText" BackColor="WhiteSmoke"></ItemStyle>
    <HeaderStyle Font-Bold="True" HorizontalAlign="Center" ForeColor="Black" VerticalAlign="Middle"
    BackColor="Control"></HeaderStyle>
    <Columns>
    <asp:TemplateColumn HeaderText="选择">
    <HeaderStyle HorizontalAlign="Center" Width="50px"></HeaderStyle>
    <ItemTemplate>
    <asp:CheckBox id="chkExport" Runat="server"></asp:CheckBox>
    </ItemTemplate>
    <EditItemTemplate>
    <asp:CheckBox id="chkExportON" Runat="server" Enabled="true"></asp:CheckBox>
    </EditItemTemplate>
    </asp:TemplateColumn>
    <asp:BoundColumn DataField="序号" ReadOnly="True" HeaderText="序号">
    <HeaderStyle Width="50px"></HeaderStyle>
    </asp:BoundColumn>
    <asp:BoundColumn DataField="名称" ReadOnly="True" HeaderText="名称">
    <HeaderStyle Width="50px"></HeaderStyle>
    </asp:BoundColumn>
    <asp:BoundColumn DataField="发布者" ReadOnly="True" HeaderText="发布者">
    <HeaderStyle Width="50px"></HeaderStyle>
    </asp:BoundColumn>
      

  2.   

    查看sql语句是否有这个字段!EnableViewState=true;
      

  3.   

    <asp:BoundColumn DataField="发布时间" ReadOnly="True" HeaderText="发布时间">
    <HeaderStyle Width="50px"></HeaderStyle>
    </asp:BoundColumn>
    <asp:BoundColumn DataField="pub_w" ReadOnly="True" HeaderText="是否发布">
    <HeaderStyle HorizontalAlign="Center" Width="50px"></HeaderStyle>
    <ItemStyle HorizontalAlign="Center"></ItemStyle>
    </asp:BoundColumn>
    <asp:TemplateColumn>
    <HeaderTemplate>
    操作
    </HeaderTemplate>
    <ItemTemplate>
    <a style="font-family: \000B ; color: navy; text-decoration: none; text-underline: none; text-line-through: none"
     href = "view_rol.aspx?id="'<%# DataBinder.Eval(Container.DataItem, "序号")%>'>查看</a> <a style="font-family: \000B ; color: navy; text-decoration: none; text-underline: none; text-line-through: none"
     href = "view_rol.aspx?id="'<%# DataBinder.Eval(Container.DataItem, "序号")%>'>修改</a>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <ItemTemplate>
    <asp:Button id="btnDelete" runat="server" Text="删除" CommandName="Delete"></asp:Button>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:datagrid><asp:button id="Button1" style="Z-INDEX: 121; LEFT: 64px; POSITION: absolute; TOP: 232px" runat="server"
    Height="24px" Width="88px" Text="选择所有"></asp:button>
    <TABLE style="Z-INDEX: 124; LEFT: 48px; POSITION: absolute; TOP: 264px">
    <tr>
    <td colSpan="10" height="11"></td>
    </tr>
    <tr>
    <td width="42" height="11">
    <div align="right"><font size="2">&gt;&gt;</font></div>
    </td>
    <td width="54" height="11">
    <div align="center"><font color="#0000a0">分 页</font></div>
    </td>
    <td width="53" height="11">
    <div align="center"><asp:linkbutton id="btnFirst" runat="server" Text="首 页" CommandArgument="First" Font-Name="verdana"
    Font-size="8pt" OnCommand="PagerButtonClick" CommandName="Pager" ForeColor="navy"></asp:linkbutton></div>
    </td>
    <td width="53" height="11">
    <div align="center"><asp:linkbutton id="btnPrev" runat="server" Text="上一页" CommandArgument="Prev" Font-Name="verdana"
    Font-size="8pt" OnCommand="PagerButtonClick" CommandName="Pager" ForeColor="navy"></asp:linkbutton></div>
    </td>
    <td width="53" height="11">
    <div align="center"><asp:linkbutton id="btnNext" runat="server" Text="下一页" CommandArgument="Next" Font-Name="verdana"
    Font-size="8pt" OnCommand="PagerButtonClick" CommandName="Pager" ForeColor="navy"></asp:linkbutton></div>
    </td>
    <td width="53" height="11">
    <div align="center"><asp:linkbutton id="btnLast" runat="server" Text="尾 页" CommandArgument="Last" Font-Name="verdana"
    Font-size="8pt" OnCommand="PagerButtonClick" CommandName="Pager" ForeColor="navy"></asp:linkbutton></div>
    </td>
    <td width="54" height="11">
    <div align="center"><font color="#0000a0">页 </font><font color="#ff0000">
    <asp:label id="lblCurrentPage" runat="server"></asp:label></font>/ <font color="#ff0000">
    <asp:label id="lblPageCount" runat="server"></asp:label></font></div>
    </td>
    <td width="73" height="11">
    <div align="center"><font color="#0000a0">共<font color="#ff0000"><asp:label id="lblRecordCount" runat="server"></asp:label>
    </font>条</font></div>
    </td>
    <td width="72" height="11">
    <div align="center"><font color="#ff0000">10</font><font color="#0000a0">条记录/页</font></div>
    </td>
    <td width="112" height="11">
    <div align="center"><font color="#0000a0">转到第
    <asp:textbox id="txtIndex" runat="server" Width="20" ForeColor="#0000A0" Columns="2" OnTextChanged="txtIndex_Changed"
    height="15" Font-Size="11px"></asp:textbox>页</font>
    </div>
    </td>
    </tr>
    </TABLE>
    </form>
    </body>
    </HTML>
      

  4.   

    EnableViewState=true;没有啊,其它字段能正常显示
      

  5.   

    看看这个有没有帮助?
    <asp:datagrid id="grd1" runat="server" OnSortCommand="Sort_Grid" AllowSorting="True" CssClass="Table" Width="100%" AllowPaging="True" BorderColor="#5A5A5A" PageSize="5">
    <SelectedItemStyle CssClass="TableSelect"></SelectedItemStyle>
    <AlternatingItemStyle CssClass="TableAltern"></AlternatingItemStyle>
    <ItemStyle CssClass="TableItem"></ItemStyle>
    <HeaderStyle CssClass="TableHead"></HeaderStyle>
    <Columns>
    <asp:TemplateColumn>
    <HeaderStyle Width="30px"></HeaderStyle>
    <ItemStyle HorizontalAlign="Center"></ItemStyle>
    <HeaderTemplate>
    <FONT size="2">选择</FONT>
    </HeaderTemplate>
    <ItemTemplate>
    <asp:CheckBox id=CheckBox1 Height="10px" ToolTip='<%# DataBinder.Eval(Container.DataItem,"单据编号") %>' Runat="server">
    </asp:CheckBox>
    <asp:Label ID="edit_billid" Visible=False Runat=server text='<%# DataBinder.Eval(Container.DataItem,"单据编号") %>'/>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    <PagerStyle Visible="False" NextPageText="后页" Height="23px" PrevPageText="前页" HorizontalAlign="Center" CssClass="TablePage" Mode="NumericPages"></PagerStyle>
    </asp:datagrid>
      

  6.   

    取值可以:((Label)grd1.Items[i].Cells[0].FindControl("edit_billid")).Text.ToString()
      

  7.   

    .cs文件中private void MyList_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) 事件还是不能执行,请各位继续发表高见,小弟在这里多谢了?
      

  8.   

    Page_Load里是否有 if(!this.Page.IsPostBack){}