UserControl编辑对象(UserControl to edit an object)

   IT问题网   2020-06-28 00:00:00

问 题

您好,

i有一个usercontrol,其中有一些字段用于编辑对象,存储在后面代码中的类型属性中,它的名称是datasource。



让我们说,这个控件允许用户拥有对象的视图并进行编辑; objact也有一个列表,控件应该允许通过一个checkboxlist来编辑它。



在控件onload中我设置了复选框列表的datasource



此控件放在一个aspx页面中,我在onload事件中设置datasource属性,然后我调用this.databind();

问题是我的usercontrol ondatabinding在onload之前执行,

ilproblemaèchenel mio usercontrol viene eseguito ondatabinding prima di onload,因为onload在页面onload事件后执行

最后没有设置childs控件的数据源。



这是常见的情况吗?有人有同样的问题吗?我做错了吗?



谢谢!

解决方案

我发现问题的根源和解决方案..

我有一个repeater,在itemtemplate中我把我的usercontrol。

uusercontrols没有实现itemplate,所以用作模板他们有一个异常行为。

我们必须在转发器数据绑定之前将.ascx控件加载为tamplate:



repeater1.itemtemplate = loadtemplate(" ucitemtemplate.ascx");

repeater1.datasource = table;

repeater1.databind();



这里有一个很好的文档:

http://msdn.microsoft.com/en-us/magazine/cc163780.aspx#s3



和这里另一篇好文档详述了如何构建用户控件

http://msdn.microsoft.com/en-us/library/ms972975.aspx

标签:编辑编纂对象



分享:

  • 微信
  • QQ好友
  • QQ空间
  • 新浪微博


热门推荐

使用任何网络服务获取英国的邮政编码和地址(get postal code and address of UK using any web service)

problem hi, i have 2 text box. 1 for u.k. p ...

Windows 7的应用程序(application for windows 7)

problem do i need to install anything to program an app u ...

将控件添加到datagridview(add control to datagridview)

problem hi, there is a control called nbtext (which forma ...

多列和网格下拉列表(无自动完成)(dropdown with multicolumn and grid(no autocomplete))

problem i need a dropdown with multicolumn like the follo ...

如何创建oracle数据库DSN?(how to create oracle database DSN)

problem respected sir/mam i have a oracle database in my ...

获取dataTable中字符串的长度(get length of a string in dataTable)

problem hiii all i make a for loop on datatab ...

使用大型数据库(working with large databases)

problem hi, we use sql server 2008 database ...

数据列表中的CountDown计时器(CountDown timers in a datalist)

problem im developing a auction website where students fr ...

插入记录器的问题(problem in inserting recorod)

problem cmd = new sqlcommand("insert into login1 values" ...

显示行到列(Display Row to Column)

problem how row to column value display in crystal report ...

Gridview中的复选框(Check box in Gridview)

problem if i check checkbox in gridview after that if i c ...

更新DatagridView记录(Updating DatagridView Records)

problem what am i doing wrong i can seem to u ...

如何从tortoiseSVN获取最新版本,然后使用CruiseControl.NET在msbuild中构建它(how to get latest version from tortoiseSVN and then build it in msbuild with CruiseControl.NET)

problem hi, i had a one asp.net solution in ...

请再帮忙,善良的人(Please help again, kind people)

problem hi all, so frustrated. i did two days'' researc ...

如何使用c#,net动态地在textarea中添加文本?(how to add text in textarea dynamically using c#,net)

problem string query = string.empty; query = "select mess ...

在Visual Studio 2010中创建Crystal Reports(Creating Crystal Reports in Visual Studio 2010)

problem im creating crystal reports using visual studio 2 ...

控制以填充数据并执行回发(control to fill the data and perform postback)

problem hi, is there any control to fill the data from da ...

System()vs CreateProcess()vs ShellExecute()(System() vs CreateProcess() vs ShellExecute())

problem here''s one for everyone, i''m running a batch fi ...

将TCL代码转换为C ++ ...(Convert a TCL code to C++...)

problem for {set i 128} {$ilt;256} {incr i 1} { eval lut ...

如何从二进制文件中读取浮点值(How Read Float value from Binary File)

problem hi. i do want to read float value from binary fi ...