[borland eco 技术]experssionhandle数据源,在datagrid中利用checkbox显示并编辑boolean类型数据
来源:互联网 发布:亚克力电脑编程设计 编辑:程序博客网 时间:2024/05/16 05:04
经过艰苦的探索,今天下午还是做出来了,贴出相关代码
环境为expressionhandle名为ehperson,是person类的全部实例 ,即express表达式person.allinstances
1.aspx文件
<ASP:DataGrid id="DataGrid1" runat="server" width="569px" height="244px" bordercolor="White" borderstyle="Ridge" borderwidth="2px" cellspacing="1" backcolor="White" cellpadding="3" gridlines="None" datasource="<%# ehperson %>" autogeneratecolumns="False" datakeyfield="ExternalId">
<FooterStyle forecolor="Black" backcolor="#C6C3C6"></FooterStyle>
<SelectedItemStyle font-bold="True" forecolor="White" backcolor="#9471DE"></SelectedItemStyle>
<ItemStyle forecolor="Black" backcolor="#DEDFDE"></ItemStyle>
<HeaderStyle font-bold="True" forecolor="#E7E7FF" backcolor="#4A3C8C"></HeaderStyle>
<Columns>
<ASP:BoundColumn datafield="name" sortexpression="name" headertext="name"></ASP:BoundColumn>
<!--模板开始textbox-->
<asp:templatecolumn>
<itemtemplate>
<asp:textbox id="text1" runat="server" enabled="False" TEXT='<%# DataBinder.Eval(Container.DataItem,"NAME")%>'></asp:textbox>
</itemtemplate>
<edititemtemplate>
<asp:textbox id="text1" runat="server" enabled="TRUE" TEXT='<%# DataBinder.Eval(Container.DataItem,"NAME")%>'></asp:textbox>
</edititemtemplate>
</asp:templatecolumn>
<!--模板结束-->
<!--模板开始checkbox-->
<ASP:TemplateColumn headertext="性别">
<ItemTemplate>
<asp:checkbox id="checkbox1" runat="server" enabled="False" checked='<%# DataBinder.Eval(Container.DataItem,"sex")%>'>
</asp:checkbox>
</ItemTemplate>
<EditItemTemplate>
<asp:checkbox id="checkbox1" runat="server" enabled="true" checked='<%# DataBinder.Eval(Container.DataItem,"sex")%>'>
</asp:checkbox>
</EditItemTemplate>
</ASP:TemplateColumn>
<!--模板结束-->
<ASP:EditCommandColumn buttontype="LinkButton" updatetext="Update" canceltext="Cancel" edittext="Edit"></ASP:EditCommandColumn>
<ASP:ButtonColumn text="Delete" commandname="Delete"></ASP:ButtonColumn>
</Columns>
<PagerStyle horizontalalign="Right" forecolor="Black" backcolor="#C6C3C6"></PagerStyle>
</ASP:DataGrid>
有颜色的部分是自定义部分,数据源是expressionhandle,名为ehperson
2在相关的.pas文件中的update事件加入两行代码,一个自定义控件模板一行
红色部分为加入
procedure TWebForm3.DataGrid_UpdateCommand(source: TObject; e: System.Web.UI.WebControls.DataGridCommandEventArgs);
var
SourceGrid: DataGrid;
Id: string;
Row: TObject;
Eh: ElementHandle;
ColIndex: Integer;
Col: BoundColumn;
begin
SourceGrid := source as DataGrid;
Id := SourceGrid.DataKeys[e.Item.ItemIndex].ToString;
SourceGrid.DataBind(); // To set DataSource
Eh := SourceGrid.DataSource as ElementHandle;
Row := eh.RenderElement(ObjectForId(Id));
for colIndex := 0 to SourceGrid.Columns.Count - 1 do
begin
Col := BoundColumn(SourceGrid.Columns[colIndex]);
if Assigned(Col) and (not Col.ReadOnly) then
eh.SetRenderedElementProperty(row, Col.DataField, (e.Item.Cells[colIndex].Controls[0] as TextBox).Text, true);
end;
eh.SetRenderedElementProperty(row, 'name', (e.Item.FindControl('text1') as textbox).text, true);
eh.SetRenderedElementProperty(row, 'sex', convert.ToString((e.Item.FindControl('checkbox1') as checkbox).Checked), true);
UpdateDatabase;
SourceGrid.EditItemIndex := -1;
DataBind;
end;
这里,sex,name分别为ehperson里面的两个字段名.convert.ToString((e.Item.FindControl('checkbox1') as checkbox).Checked) 这里只接受字符表达式,故要转换类型
- [borland eco 技术]experssionhandle数据源,在datagrid中利用checkbox显示并编辑boolean类型数据
- experssionhandle数据源,在datagrid中利用checkbox显示并编辑boolean类型数据
- 利用datagrid编辑数据
- 利用spring+ibatiS技术,在spring中配置多个数据源,并实现动态切换。
- 利用spring+ibatiS技术,在spring中配置多个数据源,并实现动态切换。
- 求VB中在DataGrid中显示Checkbox?
- 再求VB中在DataGrid中显示Checkbox?
- 在DataGrid中利用CheckBox全选所有行
- 在DataGrid中利用CheckBox全选所有行
- [borland eco]ECO中经常遇到的几个错误
- 利用GridView显示主细表并一次编辑明细表所有数据
- |在编辑框中显示数据|
- 利用双缓冲技术将位图像素数据写到DIB位图中并在指定的窗口显示(主要使用CreateDIBSection和BitBlt方法)
- 利用双缓冲技术将位图像素数据写到DIB位图中并在指定的窗口显示(主要使用CreateDIBSection和BitBlt方法)
- 从 DataGrid 或数据源中导出数据到 Excel 并提示下载的帮助类
- [borland eco 技术]自做delphi.net的eco视频教程第一讲(待续)
- DataGrid 模板列中全选CheckBox 并在删除选中后给出选择删除提示
- flex在DataGrid中添加checkbox复选框,并获取选中的值
- domino中java代理导致内存溢出问题的解决方法
- delphi中的对象其实也是一种指针
- 精通JavaScript动态网页编程(实例版)
- ERP-非财务人员的财务培训教(二)------如何评价公司/部门经营业绩
- 查看本机端口占用情况
- [borland eco 技术]experssionhandle数据源,在datagrid中利用checkbox显示并编辑boolean类型数据
- 返回eco列表集的几种方法
- dede采集过滤规则集锦
- arraylist与web 控件的绑定
- variablehandle与oclvariabl搭配使用的注意要点
- expressionhandle表达式中使用非ocl变量
- .net C# inputBox文字输入对话框,类似delphi的inputBox
- [devexpress相关控件]在gridcontrol中怎样设置满足特定条件的行的颜色等风格
- 远程调用技术代码追踪(Remobjects第三方控件)