数据源控制中查找控制中的问题 [英] Problem in find control in datasource control

查看:65
本文介绍了数据源控制中查找控制中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我在asp.net中有一个名为ucPostList的用户控件,它包含一个Asp.net DataList控件.在我的DataList控件中,我有另一个名为ucOpinion的用户控件.这两个控件都从数据库中检索数据并填充其源控件.现在,如果我想通过调用其方法ucOpinion控件来填充ucPostList,则不会填充其源代码控件.
如何调用内部控制方法?
我想在ucPostList控件中调用ucOpinion控制方法.但我无法通过

Hello dear all.

i have a user control in asp.net which is called ucPostList and it contains a Asp.net DataList control . in my DataList control i have another user control which is called ucOpinion. both two control retrive data from database and fill their source controls. now if i want to fill ucPostList by call their method ucOpinion control doesn''t fill their source control .
how i can call internal control method ?
i want to call ucOpinion control method in ucPostList control . but i can not find any ucOpinion by

ucPostList.FindControl("ucOpinion1")

推荐答案

我希望ajit为您的问题提供了解决方案.如果您仍想改进或寻找其他解决方案,请在此处-http://www.blog.dapfor.com/data-binding
I hope ajit has given the solution for your problem. If you still want to improve or looking for another solution its here- http://www.blog.dapfor.com/data-binding




首先通过在aspx页面上添加此代码来注册用户控件:

Hi ,

First Register The User Control By Adding This Code On aspx Page :

<%@ Register Src="~/WebUserControls/ucPostList.ascx" TagName="ucPostList" TagPrefix="ucPostList" %>



其次,在Cs Page中创建一个对象并找到控件:



Secondly Create a Object in Cs Page and find the Control :

ucPostList objPostList;


objPostList= (ucPostList)this.Page.FindControl("ucPostList");




创建对象后,您可以从用户控件中调用任何函数或方法.




After Creating the Object you can Call any functions Or Methods from your User Control.

objPostList.myFunction()




希望对您有帮助.




Hope This May Help You.


这篇关于数据源控制中查找控制中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆