关于GridView的绑定,和使用自带的编辑选项,急!!!
我有一个GridView
数据源来自DataSource
DataSource里面的数据来自我的一个类的一个方法,这个方法返回一个DataSet
由于数据库中键名都是英文的,所以显示出来的表头都是英文。
.aspx中的代码如下
<asp:GridView ID= "adminsGridView " runat= "server " AutoGenerateDeleteButton= "True " DataKeyNames= "id " DataSourceID= "AdminsDataSource " AllowPaging= "True " PageSize= "20 " AllowSorting= "True " AutoGenerateEditButton= "True ">
<HeaderStyle CssClass= "title " />
</asp:GridView>
<asp:ObjectDataSource ID= "AdminsDataSource " runat= "server " SelectMethod= "getAdmins " TypeName= "oe.Biz.UserDeal " DeleteMethod= "delAdmin " UpdateMethod= "updateAdmin ">
<DeleteParameters>
<asp:Parameter Name= "id " Type= "Int32 " />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name= "id " Type= "Int32 " />
<asp:Parameter Name= "username " Type= "String " />
<asp:Parameter Name= "userType " Type= "Byte " />
<asp:Parameter Name= "trueName " Type= "String " />
</UpdateParameters>
</asp:ObjectDataSource>
GridView 的 SELECT 绑定到 如下方法
public static DataSet getAdmins()
{
DataSettings settings = DataConfig.GetSettings();
oe.DataAccess.UserDeal ud = new oe.DataAccess.UserDeal(settings.ConnectionString);
DataSet admins = ud.getAdmins();
//admins.Tables[0].Columns[0] 未作设置