本文共 3060 字,大约阅读时间需要 10 分钟。
图2.这个DataGrid具有分页,Master-Detail和编辑功能。 图3.这个DataGrid具有定制控件和含有静态头部的滚动条 |
<appSettings> <add key="ConnectionString" value=" Source=(local);Initial Catalog=Northwind;User Id=sa;Password=xxx;" /> </appSettings> <httpHandlers> <add verb="POST,GET" path=" type="Ajax.PageHandlerFactory, Ajax " /> </httpHandlers> |
private void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) { WebDataGridUserControl.MainTableName="suppliers"; WebDataGridUserControl.DetailTableName = "products"; //这些可选的值将会覆盖默认的属性 WebDataGridUserControl.Height =300; WebDataGridUserControl.Width = 780; WebDataGridUserControl.Editable = 1; WebDataGridUserControl.PageSize = 4; } } |
[Ajax.AjaxMethod] public ArrayList InitializeInfo() { ... // int pageable=1; masterDetail =1;editable = 1;pageSize=10; height=300 string [] FunctionProperty = {"1", "1", gEdit, gPageSize, gridHeight, gridWidth}; //={}-没有可用控件,0-标签,1-图像,2-超级链接,3-文本框,4-复选框,5-下拉列表框 string [] ColumnControlType = {"0","2","3","3","0","3","4"}; //显示哪些列(3,4,5,7)是可编辑的 string [] ColumnEditable = {"0","0","1","1","1","0","1"}; //下列属性仅仅用于非页面支持情况下 //下列一句用于把第3,4,5列编辑按钮的尺寸重新设置为10,10,10 string [] ResetIfNoEditable = {"0","0","10","10","10", "0"}; string [] CustomizedHeadZize={"68","140","120","120","120", "0"}; //当没有页面支持设置时,需要列宽度;你应该把一列设置为"0" string [] columnWidth ={"68","140","120","120","120","0"}; ... return al; } [Ajax.AjaxMethod] public ArrayList GetHeadArray() { ... //这个数组应该匹配编辑字段-column3=Decimal,column4=Email,column5=Number string [] ValidateType = {"","","Decimal","Email","Number"}; //赋值ColumnDisplayName = {};如果不使用定制显示名 string [] ColumnDisplayName = {}; ... } |
最后,十分感谢Michael Schwarz,是他创建了搭建起JavaScript与.Net之间桥梁的ajax.net。
本文转自朱先忠老师51CTO博客,原文链接: http://blog.51cto.com/zhuxianzhong/59746,如需转载请自行联系原作者