从父页面到Web服务器控件获取dropdownllist选择的值 [英] get dropdownllist selected value from parent page to web server control

查看:60
本文介绍了从父页面到Web服务器控件获取dropdownllist选择的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Genius,

我的项目在过去6-7小时内出现问题。

我正在使用Web服务器控件创建动态控件根据父页面下拉列表的选择(控制调用页面)。

因此,根据下拉列表值,网络服务器将重新生成控件。



现在,我的代码分析:

我用

Hello Genius,
I am having a problem from last 6-7 hours in my project.
I am using a web server control where I am creating dynamic control according to selection of a dropdownlist of parent page(the control calling page).
So, According to the dropdownlist value the webserver will re-generate the controls.

Now, My code analysis:
I am creating properly the controls with

protected override void CreateChildControls()
{
 // addding control stuff here..
}
protected override void RenderContents(HtmlTextWriter output)
{
 // render the controls stuff here..
}



控件正在成功创建。

现在问题:

当我从父页面更改下拉列表数据时,调用CreateChildControls()方法但未获取更改下拉列表选定值。因此,此方法使用以前选择的数据。因为在执行CreateChildControls()方法之后,会触发SelectedIndexChanged事件。



我已经搜索了许多链接,但没有找到答案。任何人都可以给出正确的解决方案。

谢谢。


The controls are creating successfully.
Now Problem:
When I am changing the dropdownlist data from parent page, the "CreateChildControls()" method calling but the Changing dropdown selected value is not getting. So, This method working with previous selected data. Because After Executing CreateChildControls()method, the SelectedIndexChanged event fires.

I already searched many links but didn't find the answer. Can any body give the proper solution.
Thanks.

推荐答案

你可以这样使用

you can use like this
protected void Page_Init(object sender, EventArgs e)
       {
           try
           {
               DropDownList ddlParent =(DropDownList)Master.FindControl("ddlParent");
               if (ddlParent != null)
               {
                   ddlParent .SelectedIndexChanged += new EventHandler(lnkReferesh_Click);
               }
           }
           catch (Exception ex)
           {
               throw ex;
           }
       }





:设置正确的代码块。



:Set proper code block.


这篇关于从父页面到Web服务器控件获取dropdownllist选择的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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