vs2003升级vs2005 DataGrid 排序问题
我的aspx页面
<asp:datagrid id="MyDataGrid1" runat="server" Width="1050px" AllowSorting="True" AutoGenerateColumns="False"
PageSize="50" AllowPaging="True" ShowFooter="True" EnableViewState="False" OnSortCommand="MyDataGrid1_SortCommand">
<Columns>
<asp:TemplateColumn HeaderText="选择">
<HeaderStyle Width="50px"></HeaderStyle>
<ItemTemplate>
<FONT face="宋体">
<asp:HyperLink id="HyperLink1" runat="server">明细</asp:HyperLink></FONT>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn Visible="False" DataField="行政村" HeaderText="行政村"></asp:BoundColumn>
<asp:BoundColumn DataField="pname" HeaderText="姓名">
<HeaderStyle Width="50px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="性别" HeaderText="性别"></asp:BoundColumn>
<asp:BoundColumn DataField="medicareid" SortExpression="medicareid" HeaderText="医疗证号">
<HeaderStyle Width="100px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="billcode" SortExpression="billcode" HeaderText="单据编码">
<HeaderStyle Width="145px"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="billdate" SortExpression="billdate" HeaderText="单据日期" DataFormatString="{0:yyyy-MM-dd}">
<HeaderStyle Width="90px"></HeaderStyle>
<FooterStyle HorizontalAlign="Center"></FooterStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="moneys" HeaderText="总费用" DataFormatString="{0:#,##0.00}">
<HeaderStyle Width="90px"></HeaderStyle>
<ItemStyle HorizontalAlign="Right"></ItemStyle>
<FooterStyle HorizontalAlign="Right"></FooterStyle>
</asp:BoundColumn>
</Columns>
</asp:datagrid>
后台cs
protected void MyDataGrid1_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
{
DataSet ds = new DataSet ();
DataView dv = null;
try
{
if(!this.bind(out ds)) throw new ApplicationException("获取数据出错");
dv = new DataView (ds.Tables[0]);
dv.Sort = e.SortExpression;
this.MyDataGrid1.DataSource = dv;
MyDataGrid1.DataBind();
}
catch(Exception ex)
{
this.errMsg = ex.Message;
}
}
}
现在的问题是 在页面已经写了 SortExpression 的,如 单据日期这一列,可以自动排序,而现在我想在 总费用 列上面
加上 SortExpression="moneys" ,让总费用自动排序,但是一点击 ,页面的datagrid 就消失了,一片空白,我的系统是vs2003 升级到vs2005 的,不知道跟这个有没有关系,请高人赐教!