DataGrid问题--新手求救

galaxy001 2005-04-11 03:42:53
*.aspx 中<%# DataBinder.Eval(Container.DataItem, "序号")%>得不到值
*.aspx.cs中private void MyList_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) 事件不执行,请问是怎么回事?
上面问题是在加入分页后才出现的
...全文
124 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaogueizi 2005-04-15
  • 打赏
  • 举报
回复
Page_Load里是否有 if(!this.Page.IsPostBack){}
powerpower111 2005-04-15
  • 打赏
  • 举报
回复
老兄,看CS初始化中有没添加这个事件的声明,就 ..+=..
galaxy001 2005-04-15
  • 打赏
  • 举报
回复
.cs文件中private void MyList_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) 事件还是不能执行,请各位继续发表高见,小弟在这里多谢了?
ArronLi 2005-04-11
  • 打赏
  • 举报
回复
取值可以:((Label)grd1.Items[i].Cells[0].FindControl("edit_billid")).Text.ToString()
ArronLi 2005-04-11
  • 打赏
  • 举报
回复
看看这个有没有帮助?


<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>
fantiny 2005-04-11
  • 打赏
  • 举报
回复
每次点下一页后有重新帮定吗?需要重新绑定数据库的。
LoveCherry 2005-04-11
  • 打赏
  • 举报
回复
数据库字段改了吗?
有序号字段吗
galaxy001 2005-04-11
  • 打赏
  • 举报
回复
我的QQ:117780606
原先运行正常,但加入分页后边出现了上面的问题?请问是怎么回事?
galaxy001 2005-04-11
  • 打赏
  • 举报
回复
我在线等着,谁给我解决了我再送他100分,可以加QQ聊,或电话0531-8060927
我急需你们的帮助!
chengbo1983 2005-04-11
  • 打赏
  • 举报
回复
好晕,看看你的CS呢?
galaxy001 2005-04-11
  • 打赏
  • 举报
回复
EnableViewState=true;没有啊,其它字段能正常显示
galaxy001 2005-04-11
  • 打赏
  • 举报
回复
<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">>></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>
baobei7758 2005-04-11
  • 打赏
  • 举报
回复
查看sql语句是否有这个字段!

EnableViewState=true;
galaxy001 2005-04-11
  • 打赏
  • 举报
回复
<%@ 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>
sunnystar365 2005-04-11
  • 打赏
  • 举报
回复
讲清楚一点,楼主,我听的不太明白

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧