473,789 Members | 2,106 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Event & Delegets

I have master datagrid & master details in 5 panels each belong to diffrent
dbtable. I have a dropdpwn list to switch which panel to be visible..

I also have one navigation bar for add, update, delete and i need to the
button to work with the visible panel but the click event don't fire, here
is my code for the dropdownlist selectedindex change:

private void DropDownList1_S electedIndexCha nged(object sender,
System.EventArg s e)
{
switch(DropDown List1.SelectedI ndex)
{
case 0 :
ResetPanelVisib lity();
Panel1_Personal Info.Visible = true;
this.bt_new.Cli ck += new EventHandler(th is.Panel1_NewRe cord);
this.bt_edit.Cl ick += new EventHandler(th is.Panel1_Updat eRecord);
this.bt_delete. Click += new EventHandler(th is.Panel1_Delet e);
break;

case 1:
ResetPanelVisib lity();
Panel2_Photo.Vi sible = true;
this.bt_new.Cli ck += new EventHandler(th is.Panel2_NewRe cord);
this.bt_edit.Cl ick += new EventHandler(th is.Panel2_Updat eRecord);
this.bt_delete. Click += new EventHandler(th is.Panel2_Delet e);
break;
------------------------------------------------
if i implement a switch case(or if statment) for each button to call methods
it' work.
So How can i fix this problem without use switch case for each button click
event??
regards

Nov 19 '05 #1
3 1569
Can you use a single set of event handlers for all grids? In the event
handler you could check the selected index of the dropdown list and
take the appropriate action. If you do this, you won't need to switch
event handlers for the buttons.

Now you're only left with making the correct panel visible in your
DropDownList1_S electedIndexCha nged event handler. You can make this
generic by using something like

System.Web.UI.W ebControls.Pane l
objPanel=this.F indControl("Pan el"+Convert.ToS tring(DropDownL ist1.SelectedIn dex+1));
objPanel.Visibl e=true;

to locate the panel that goes with the selected index. Change the
names of the panels so they are Panel1, Panel2, Panel3, etc.

I hope this helps.

Bill E.
Hollywood, FL

Nov 19 '05 #2
Thanx for ur solution..
but doing so mean i will switch in each button handler for the dropdown
selected index... right??
which mean there will be 8 switch case for 8 buttons..
while this is related to the visible panel which is selected by the
dropdownlist so i want to handle all the switching prossess in the
DropDownList selectedIndex change..

can i work around to solve this prblem??
<bi********@net scape.net> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Can you use a single set of event handlers for all grids? In the event
handler you could check the selected index of the dropdown list and
take the appropriate action. If you do this, you won't need to switch
event handlers for the buttons.

Now you're only left with making the correct panel visible in your
DropDownList1_S electedIndexCha nged event handler. You can make this
generic by using something like

System.Web.UI.W ebControls.Pane l
objPanel=this.F indControl("Pan el"+Convert.ToS tring(DropDownL ist1.SelectedIn dex+1));
objPanel.Visibl e=true;

to locate the panel that goes with the selected index. Change the
names of the panels so they are Panel1, Panel2, Panel3, etc.

I hope this helps.

Bill E.
Hollywood, FL

Nov 19 '05 #3
I'm not sure why there must be a switch in the event handlers for the
panels. Are you doing INSERTS, UPDATES and DELETES in these handlers?
Are the operations basically the same for each panel, but perhaps a
different stored procedure is called? If so, you can store the
different procedures in an array and reference the index of the array
using DropDownList1.S electedIndex.

On the other hand, If the operations are very different for each panel,
it becomes more likely that you'll need a switch somewhere in those
event handlers.

Bill

Nov 19 '05 #4

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

Similar topics

8
2819
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);" TextBox2.Attributes.Add("onKeyPress", jscode) You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as &amp;&amp; in the code that is
8
2325
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);" TextBox2.Attributes.Add("onKeyPress", jscode) You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as &amp;&amp; in the code that is
4
3946
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);" TextBox2.Attributes.Add("onKeyPress", jscode) You will notice that jscode contains the JavaScript Logical And operator (&&). However, ASP.NET renders this as &amp;&amp; in the code that is
0
9659
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
10400
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
10190
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
10134
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
9977
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
6754
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
5413
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
5545
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3692
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.