473,788 Members | 2,706 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strange problem of Dynamic Checkbox

I'm comparing two strings and trying to check a dynamic checkbox when
its true on pageload , but i dont know why i'm not able to do that on
page load, when i click some other links and come back to this page
then the required checkbox will be checked. I'm not able to figure out
where is the problem. Sorry about the long code
Any help will be greatly appreciated

private void Page_Load(objec t sender, System.EventArg s e)
{
if(!IsPostBack)
{
get_servc();
}
}
override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
if (Page.IsPostBac k)
{
Session.Timeout =120;
_checkboxes = (ArrayList) Session["CheckBoxAr ray"];
}
else
{
_checkboxes = new ArrayList();
get_servc();
}

foreach(CheckBo x c1 in _checkboxes)
Panel1.Controls .Add(c1);
}
public void get_servc()
{
strcatgy = Convert.ToStrin g(Session["Category"]);
string temp = strcatgy;
int xPos = 20;
int yPos= 335;
int count=0;
objcmd = new SqlCommand("Sel ectDynControls" , objConn);
objcmd.CommandT ype = CommandType.Sto redProcedure;
objConn.Open();
objRdr=objcmd.E xecuteReader();
while(objRdr.Re ad())
{
CheckBox c1 = new CheckBox();
c1.ID="chk" + _checkboxes.Cou nt.ToString();
c1.AutoPostBack =true;
c1.Visible=true ;
c1.Text = Convert.ToStrin g(objRdr["CbName"]);
if(c1.Text == temp)
{
c1.Checked=true ; // this is the part which is not working
}

c1.Style.Add("D ISPLAY", "BLOCK");
if((count % 6)==0)
{
yPos +=30;
xPos =20;
}
c1.Style.Add("P OSITION", "absolute") ;
c1.Style.Add("T OP", Convert.ToStrin g(yPos));
c1.Style.Add("L EFT", Convert.ToStrin g(xPos));
_checkboxes.Add (c1);
Panel1.Controls .Add(c1);
xPos += 120;
count += 1;
}
objRdr.Close();
objConn.Close() ;
yPos = yPos + 50;
xPos = 275;
}

Nov 19 '05 #1
1 1279
Actually the code had no problem
As I was creating the dynamic controls prior to page load. we have to
call method get_servc() again as shown in my code below
and now its working
hope this will be of some help to the people who stuck with the same
problem
private void dl_Edit(object source,
System.Web.UI.W ebControls.Data ListCommandEven tArgs e)
{
strcatgy =((Label)e.Item .FindControl("l blcategory")).T ext;
Session["Category"]= strcatgy;
get_servc();
............
...........
............
}

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2151
by: pizzy | last post by:
INTRO: I tried to clean it up for easy reading. I hope I didn't make any mistakes. PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see "TAGSELECTED") to print my textboxes (see "TAG#") when more than 1 number (see "VLANS") is inputed into my form. QUESTION: How do I make my dynamic form have a dynamic input box(which is created by checking the checkbox and calling the functionC1) inside it and still be able to pass the...
3
3986
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which step you're on. This all works fine, but I ran into some trouble when I started creating controls dynamically in my code-behind file. Each panel contains a table which is filled with various radio buttons, text fields and the such which are...
5
4038
by: Irfan Akram | last post by:
Hi Mr.Steve, First of all many thanks for your kind response. The thing is that I am trying to control the user's action of deselecting a checkbox, once he has selected it. Also the checkbox has been generated dynamically. If it is selected I do some other processing, so if it is then deselected then the whole page has to be resetted, hence the sense of displaying the warning message. The problem is that I dont want the warning message...
11
1926
by: Dagwood Bumstead | last post by:
I play around with js a little... I just don't get this. The file below is just trying out some things... it does exactly what I want (hides/displays some things, no big deal) The problem is that in the swapcheck(x) function below, if I uncomment the first line (commented with //) the whole thing brings and IE errors the page with an object expected error on line (whichever input control I clicked).
3
1914
by: Raymond | last post by:
I am having a problem about the dynamic checkbox Private Sub Page_Load Me.NumberOfChkControls = 0 Dim cbCheckBox As New CheckBox cbCheckBox.Text = .Id.ToString cbCheckBox.ID = "ControlID_" + NumberOfChkControls.ToString NumberOfChkControls = NumberOfChkControls + 1 cbCheckBox.EnableViewState = True dimNewTableCell.Controls.Add(cbCheckBox) dimNewTableRow.Cells.Add(dimNewTableCell)
0
1348
by: =?Utf-8?B?SWRlcm9ja3M=?= | last post by:
Hi All, I created a dynamic checkbox in ASP .Net inside a Button1_Click event method (outside the page_load event) and performed the event handling method for the CheckedChanged event and I check the checkbox at runtime nothing happens (checkBoxObj.check is always false). Does anyone have information on how to make this work? Note: I can get it to work inside Page_Load event. I need help in getting it to work in different event...
1
6020
by: iderocks | last post by:
Hi All, I created a dynamic checkbox in ASP .Net inside a Button1_Click event method (outside the page_load event) and performed the event handling method for the CheckedChanged event and when I check the checkbox at runtime nothing happens (checkBoxObj.check is always false). Does anyone have information on how to make this work? Note: I can get it to work inside Page_Load event. I need help in getting it to work in a different event...
2
2640
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to update the information which is stored in a SQL database. In testing we noticed that the form was updating correctly but the update mechanism was also updating the first record of the table in the sql database every time. No error messages are on...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10177
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...
1
10113
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
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...
1
7519
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
6750
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
5402
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...
0
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3677
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.