473,804 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with maintaining value of dynamic control

29 New Member
hi all ,

i am mess with the one situation.

i am using asp.net2.0 ,C# and sql server 2005.

I have checkboxlist and based on user selection i creates dynamic controls(which code is in filterbutton_Cl ick event and i call createcontrols function(public ) in that ).But when i select value of that control(dynamic created) in another button click event(searchbut ton) first it create fuction does not create dynamic control second as a result i do not get value of the control i call create function in filterbutton click and oninit()[
please help

my create function is


Expand|Select|Wrap|Line Numbers
  1. private void createcontrols()
  2. {
  3.  
  4. i = 1;
  5.  
  6. //if (CheckBoxListmst.SelectedIndex > -1)
  7.  
  8. //{
  9.  
  10. foreach (ListItem li in CheckBoxListmst.Items)
  11. {
  12.  
  13. if (li.Selected == true)
  14. {
  15.  
  16. Label label = new Label();
  17.  
  18. DropDownList dropdownlist = new DropDownList();
  19.  
  20. label.ID = "label" + i.ToString();
  21.  
  22. label.EnableViewState = true; 
  23.  
  24. dropdownlist.ID = "dropdownlist" + i.ToString();
  25.  
  26. dropdownlist.EnableViewState = true ;
  27.  
  28.  
  29. label.Text = li.Text;
  30.  
  31. //Label1.Text += dropdownlist.ID ;
  32.  
  33. i++;
  34.  
  35. //rdr = cmd.ExecuteReader();
  36.  
  37. for (int j = 0; j < 5; j++ )
  38. {
  39.  
  40. ListItem ld = new ListItem();
  41.  
  42. ld.Text = j.ToString() ;
  43.  
  44. ld.Value = j.ToString();
  45.  
  46. dropdownlist.Items.Add(ld);
  47.  
  48. }
  49.  
  50. PlaceHolder1.Controls.Add(label);
  51.  
  52. PlaceHolder1.Controls.Add(dropdownlist);
  53.  
  54.  
  55.  
  56. Response.Write("<br>");
  57.  
  58.  
  59. }
  60.  
  61. }
  62.  
  63. }
  64.  
  65. // }
  66.  
  67. }
  68.  
  69.  
and i access it with the code as
Expand|Select|Wrap|Line Numbers
  1. Label objlbl;
  2.  
  3. DropDownList objdrop;
  4.  
  5. objlbl = this.PlaceHolder1.FindControl("label1") as Label;
  6.  
  7. objdrop = this.PlaceHolder1.FindControl("dropdownlist1") as DropDownList;
  8.  
  9. if ((objlbl != null) && (objdrop.SelectedIndex > -1 ))
  10.  
  11. {
  12.  
  13. Label1.Text = objlbl.Text; //Page.FindControl("label1").ToString() ;
  14.  
  15. Label2.Text = objdrop.SelectedValue;
  16.  
  17. }
  18.  
  19.  


i call createcontrol funtion in filterbutton_cl ick and override oninit()


thank you
Jul 27 '07 #1
0 1156

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1847
by: Andy | last post by:
Hi, I am complete JavaScript novice and would really appreciate some help with this code: ===================================================================== <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> <!--#include file="Connections/ssdb.asp" -->
1
5643
by: Mike | last post by:
I create a dynamic control and added it to a panel. I get the selected value of the control via a btn_click() but my problem is everytime the page is postback the selected values go back to the first element in the dropdownlist. but if i call the control creation with if !=postback then the controls disappear. and selected values = null. Any help on this would be great
0
1010
by: Kalyani | last post by:
Hi, I have a page with one DropDownList and a Placeholder.This placeholder wil contain either a textbox or a DropDownList depending upon the value in previous DropDownList. Also there is a Submit button and on click of this event values in thse controls are processed and selected value in previous DropDownList ( static one ) gets removed. Now to show this updated list in the static DropDownList I need to re-populate the DropDownList...
3
2272
by: Eric | last post by:
I have built a composite user web control that I want to create dynamically. The form will contain a variable number of these controls and as well some of the contents of the user web control itself are dynamically created controls. I create as follows: wcGroupControl oGroupControl = new wcGroupControl(); I then tried calling methods of the control passing dynamic controls as parameters that need to be added to the web controls on the...
1
1920
by: pbb | last post by:
I'm creating a set of dynamic controls on a webpage by calling my BuildControls sub in the Page_Init sub. I recreate the controls by calling the BuildControls sub in the LoadViewState override procedure. The set of controls will not always be the same (based on the selection the user makes in a static ddl). The controls are persisted perfectly. The problem I'm experiencing is that when one of the dynamic ddl's (let's say ddl1) is...
1
1312
by: Kalyani | last post by:
Hi, I have a page with one DropDownList and a Placeholder.This placeholder wil contain either a textbox or a DropDownList depending upon the value in previous DropDownList. Also there is a Submit button and on click of this event values in thse controls are processed and selected value in previous DropDownList ( static one ) gets removed. Now to show this updated list in the static DropDownList I need to re-populate the DropDownList...
3
2138
by: ThunderMusic | last post by:
Hi, I have a custom control that draws many thing on the screen including a hidden field. This hidden field's value is modified through client code. What I want to do is the following : When there is a postback of the page, I want this hidden field to keep it's value (from the viewstate or something like this). Is there an easy solution? Would you need the code. Right now I : create a HiddenField in the PreRender of my control store...
3
1430
by: Tomasz J | last post by:
Hello Developers, I have a control derived from System.Web.UI.WebControls.WebControl. Control has this property: public string Value { set { _value = value; } get { return _value; }
0
1873
by: rcon | last post by:
I'm creating a user control to prompt for crystal reports parameters. The individual controls work fine, and the over all control works fine too. However, I'm not really that experienced in the use of dynamic controls and am having some issues with getting the accordion to work properly. What happens when one of my user controls fires a postback is that the accordion gets set back to the first pane. I suspect that this is happening...
0
10595
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10089
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9171
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5530
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.