473,714 Members | 2,490 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating Handler for Dynamic DropDownList

Hie,
I create a dynamique HtmlTable, in each cell of this HtmlTable put a new control ( dropdownlist,la bel,..) and then want to create handler so that if i change the select item in the dop downlist i change the text displayed in the label in the same row.
hier is my code:

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using System.Data.Sql Client;

namespace gestion_commerc iale
{
/// <summary>
/// Description résumée de [!output SAFE_CLASS_NAME].
/// </summary>
public class bon : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Labe l xnumbon;
protected System.Web.UI.W ebControls.Labe l xcompte;
protected System.Web.UI.W ebControls.Labe l xdate;
protected System.Web.UI.W ebControls.Labe l xcode;
protected System.Web.UI.W ebControls.Drop DownList xclient;
protected System.Web.UI.W ebControls.Text Box xnbre;
protected System.Web.UI.H tmlControls.Htm lTable Table1;

private void Page_Load(objec t sender, System.EventArg s e)
{
if (!IsPostBack )
{
string sql_cl= "SELECT nom_client FROM client order by nom_client asc";
NumBon numero_bon = new NumBon();

xnumbon.Text = numero_bon.getN umBon().ToStrin g();

xcompte.Text= Session["compte"].ToString();
DataBase db= new DataBase();
db.setDbConnect ion();
db.getDbConnect ion().Open();
RecordSet rs = new RecordSet(sql_c l,db.getDbConne ction());
xclient.DataSou rce = rs.execSelect() ;
xclient.DataTex tField = "nom_client ";
xclient.DataBin d();

}

}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGENÂ*: Cet appel est requis par le Concepteur Web Form ASP.NET.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
/// le contenu de cette méthode avec l'éditeur de code.
/// </summary>
private void InitializeCompo nent()
{
this.xnbre.Text Changed += new System.EventHan dler(this.xnbre _TextChanged);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void xnbre_TextChang ed(object sender, System.EventArg s e)
{

int numrows = Convert.ToInt32 (xnbre.Text);
// boucle selon le nombre de produit

// get the number of rows and cells to build

// loop through the given number of rows
for ( int r = 0; r < numrows; r++ )
{
// instantiate a new row
HtmlTableRow row = new HtmlTableRow ( );

// set bgcolor for alternating rows
if ( r % 2 == 1 ) row.BgColor = "beige";

// loop through the given number of cells
for ( int c = 0; c < 8; c++ )
{
// instantiate a new cell
HtmlTableCell cell = new HtmlTableCell ( );

// add cell content
if(c==4)
{

DropDownList stationDifusion = new DropDownList();
stationDifusion .ID="st"+r+"";
//stationDifusion .SelectedIndexC hanged += new System.EventHan dler(this.stati onDifusion_Sele ctedIndexChange d);//
stationDifusion .Width=100;
//creation d'un array liste
ArrayList station=new ArrayList( );
station.Add("Tà ©lévision");
station.Add("Ra dio RSI");
station.Add("Ch aîne Nationale");
station.Add("Da kar FM" );
station.Add("St Louis FM");
station.Add("Lo uga FM");
station.Add("Th ies FM");
station.Add("Ka olack FM");
station.Add("Di ourbel FM");
station.Add("Ko lda FM");
station.Add("Zi guinchor FM");
station.Add("Ta mba FM");
station.Add("Fa tick FM");
station.Add("Sy nchronisation") ;
stationDifusion .DataSource=sta tion;// fin array liste
stationDifusion .DataBind();
cell.Controls.A dd (stationDifusio n);
}
else if (c==2)
{
DropDownList ddl = new DropDownList();
ddl.ID="hd"+r+" ";
ddl.Width=100;
//creation d'un array liste
ArrayList heuredifusion=n ew ArrayList ( );
heuredifusion.A dd ( "12h:30" );
heuredifusion.A dd ( "13h:00" );
heuredifusion.A dd ( "14h:00" );
heuredifusion.A dd ( "14h:15" );
heuredifusion.A dd ( "15h:00" );
heuredifusion.A dd ( "17h:00" );
heuredifusion.A dd ( "19h:30" );
heuredifusion.A dd ( "20h:00" );
heuredifusion.A dd ( "20h:30" );
heuredifusion.A dd ( "21h:00" );
heuredifusion.A dd ( "23h:30" );
heuredifusion.A dd ( "23h:45" );
ddl.DataSource= heuredifusion;// fn array liste
ddl.DataBind();
cell.Controls.A dd (ddl);

}
else if (c==6)
{
DropDownList ddl = new DropDownList();
DropDownList ddlHeureDifusio n = new DropDownList();
ddlHeureDifusio n.ID="maj"+r+"" ;
ddlHeureDifusio n.Width=100;
//creation d'un array liste
ArrayList majoration=new ArrayList ( );
majoration.Add ( "0" );
majoration.Add ( "5" );
majoration.Add ( "10" );
majoration.Add ( "15" );
majoration.Add ( "20" );
majoration.Add ( "25" );
majoration.Add ( "30" );
majoration.Add ( "35" );
majoration.Add ("40" );
majoration.Add ( "45" );
majoration.Add ( "50" );
majoration.Add ( "55" );
majoration.Add ( "60" );
majoration.Add ( "65" );
majoration.Add ( "70" );
majoration.Add ( "75" );
majoration.Add ( "80" );
majoration.Add ( "85" );
majoration.Add ( "90" );
majoration.Add ( "95" );
majoration.Add ( "100" );
ddl.DataSource = majoration;// fin array liste
ddl.DataBind();
cell.Controls.A dd (ddl);
}
else if(c==0)
{
string sql_query="sele ct nom_prod,pu from produit order by nom_prod asc";
//cell.Controls.A dd ( new HtmlInputText() );

DropDownList ddlDesi = new DropDownList();
DropDownList ddlPU = new DropDownList();
//*************** *************** *************** ******
DataBase db= new DataBase();
db.setDbConnect ion();
db.getDbConnect ion().Open();
RecordSet rs = new RecordSet(sql_q uery,db.getDbCo nnection());
ddlDesi.DataSou rce = rs.execSelect() ;
ddlDesi.DataTex tField = "nom_prod";
ddlDesi.DataBin d();
cell.Controls.A dd (ddlDesi);
}
else if(c==1)
{
HtmlInputText itnom=new HtmlInputText() ;
itnom.Size=10;
cell.Controls.A dd(itnom);
}
else if(c==3)
{
HtmlInputText itqte=new HtmlInputText() ;
itqte.Size=2;

cell.Controls.A dd(itqte);
}

// add the cell to the Cells collection
row.Cells.Add ( cell );
}
// add the row to the Rows collection
Table1.Rows.Add (row);
}
}
}
}
---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Jul 21 '05 #1
0 1666

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

Similar topics

2
4569
by: Patrick | last post by:
I want to define a set of web-form templates in XML and render the equivalent web-form with ASP.NET, then process any input server controls on the form. Reading the XML file from Page_load is easy, but 1) How do I set about dynamically creating user controls (like TextBox, TextArea) --- simply Declare and initialised (new) the user controls?? How do I "place" it graphically on the form. Ideally, I want them to lay out in a table, one...
0
1565
by: DotNetJunkies User | last post by:
Hie, I create a dynamique HtmlTable, in each cell of this HtmlTable put a new control ( dropdownlist,label,..) and then want to create handler so that if i change the select item in the dop downlist i change the text displayed in the label in the same row. hier is my code: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web;
4
4197
by: TS | last post by:
I am creating a User control and i create some dynamic controls in the init handler. one of the controls is a custom validator which i assign a serverValidate event handler. I usally always do my controls as custom server controls and don't understand why this event won't fire. I figured if the creation of the control was in the init, it would be initialized and have its event handlers set up, then after Load, the control would call its...
9
3627
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have to create the dynamic controls in the OnInit stage of the lifecycle. Since data from static controls is not yet available in the OnInit stage I can't know what dynamic control I have to create.
0
8701
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9306
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...
1
9068
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
9009
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
7942
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...
0
5943
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
4462
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...
2
2510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2103
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.