Click here to Skip to main content
15,901,284 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Help with DataReader Pin
Chetan Ranpariya25-Apr-07 2:14
Chetan Ranpariya25-Apr-07 2:14 
GeneralRe: Help with DataReader Pin
kallileo25-Apr-07 2:45
kallileo25-Apr-07 2:45 
GeneralRe: Help with DataReader Pin
Chetan Ranpariya25-Apr-07 23:12
Chetan Ranpariya25-Apr-07 23:12 
GeneralRe: Help with DataReader Pin
kallileo25-Apr-07 23:35
kallileo25-Apr-07 23:35 
GeneralRe: Help with DataReader Pin
Chetan Ranpariya25-Apr-07 23:45
Chetan Ranpariya25-Apr-07 23:45 
GeneralRe: Help with DataReader Pin
kallileo26-Apr-07 0:03
kallileo26-Apr-07 0:03 
GeneralRe: Help with DataReader Pin
Chetan Ranpariya26-Apr-07 0:08
Chetan Ranpariya26-Apr-07 0:08 
GeneralRe: Help with DataReader Pin
Chetan Ranpariya26-Apr-07 0:34
Chetan Ranpariya26-Apr-07 0:34 
Hi,

I hope the following solution will help you.

You create a common event handler for the command event of all your switchbuttons.

public void bttns_command(object sender, CommandEventargs e)
{
if(e.CommandName == "Switch1")
{
//do work related to switch1;
if(Label1.Text == "ON")
{
query = "Update ..........."
ChangeButton("Switch1",0);
}
else
{
query = "update............."
ChangeButton*("Switch1",1);
}
updateCMD = New SqlCommand(query, SQLconn)
updateCMD.CommandType = CommandType.Text
SQLconn.Open()
updateCMD.ExecuteNonQuery()
SQLconn.Close()
}
else if(e.CommandName == "Switch2")
{
if(Label2.Text == "ON")
{
query = "Update ..........."
ChangeButton("Switch2",0);
}
else
{
query = "update............."
ChangeButton*("Switch2",1);
}
updateCMD = New SqlCommand(query, SQLconn)
updateCMD.CommandType = CommandType.Text
SQLconn.Open()
updateCMD.ExecuteNonQuery()
SQLconn.Close()
}
else if(e.CommandName == "Switch3")
{
if(Label3.Text == "ON")
{
query = "Update ..........."
ChangeButton("Switch3",0);
}
else
{
query = "update............."
ChangeButton*("Switch3",1);
}
updateCMD = New SqlCommand(query, SQLconn)
updateCMD.CommandType = CommandType.Text
SQLconn.Open()
updateCMD.ExecuteNonQuery()
SQLconn.Close()
}
}

The html for your buttons should look like following.

<asp:Button id="bttnSwitch1" Runat="server" CommandName = "Switch1"
OnCommand="bttns_command"></asp:Button>
<asp:Button id="bttnSwitch2" Runat="server" CommandName = "Switch2"
OnCommand="bttns_command"></asp:Button>
<asp:Button id="bttnSwitch3" Runat="server" CommandName = "Switch3"
OnCommand="bttns_command"></asp:Button>

Now you ChangButton function shuld look like following:
private void ChangeButton(string switchname, bool status)
{
if(switchname == "Switch1")
{
if(status)
{
Label1.Text = "ON";
OnOff1.Style.Value = "background-image: url(../ImgContr/1.png);"
}
else
{
Label1.Text = "OFF"
OnOff1.Style.Value = "background-image: url(../ImgContr/2.png);"
}
}
else if(switchname == "Switch2")
{
if(status)
{
Label2.Text = "ON";
OnOff2.Style.Value = "background-image: url(../ImgContr/1.png);"
}
else
{
Label2.Text = "OFF"
OnOff2.Style.Value = "background-image: url(../ImgContr/2.png);"
}
}
else if(switchname == "Switch3")
{
if(status)
{
Label3.Text = "ON";
OnOff3.Style.Value = "background-image: url(../ImgContr/1.png);"
}
else
{
Label3.Text = "OFF"
OnOff3.Style.Value = "background-image: url(../ImgContr/2.png);"
}
}
}

I hope this will help you.



Thanks and Regards,
Chetan Ranpariya1
GeneralRe: Help with DataReader Pin
kallileo26-Apr-07 0:39
kallileo26-Apr-07 0:39 
Questionjavascript Function Pin
siddisagar25-Apr-07 1:14
siddisagar25-Apr-07 1:14 
AnswerRe: javascript Function Pin
Christian Graus25-Apr-07 2:07
protectorChristian Graus25-Apr-07 2:07 
GeneralRe: javascript Function Pin
gus_br25-Apr-07 2:55
gus_br25-Apr-07 2:55 
QuestionWeb Parts Very Cool ??? Pin
Rahul_asp.net25-Apr-07 1:01
Rahul_asp.net25-Apr-07 1:01 
AnswerRe: Web Parts Very Cool ??? Pin
szukuro25-Apr-07 1:13
szukuro25-Apr-07 1:13 
QuestionDataGrid Sorting Problem Pin
sonia_basangar25-Apr-07 0:54
sonia_basangar25-Apr-07 0:54 
AnswerRe: DataGrid Sorting Problem Pin
RSArockiam25-Apr-07 1:35
RSArockiam25-Apr-07 1:35 
AnswerRe: DataGrid Sorting Problem Pin
Chetan Ranpariya25-Apr-07 2:07
Chetan Ranpariya25-Apr-07 2:07 
QuestionASP RichTextBox Pin
Socheat.Net25-Apr-07 0:44
Socheat.Net25-Apr-07 0:44 
AnswerRe: ASP RichTextBox Pin
Sathesh Sakthivel25-Apr-07 0:59
Sathesh Sakthivel25-Apr-07 0:59 
AnswerRe: ASP RichTextBox Pin
Haissam25-Apr-07 10:01
Haissam25-Apr-07 10:01 
QuestionHow to print the items in a datagrid in ASP .Net Pin
Balagurunathan S25-Apr-07 0:16
Balagurunathan S25-Apr-07 0:16 
AnswerRe: How to print the items in a datagrid in ASP .Net Pin
N a v a n e e t h25-Apr-07 1:06
N a v a n e e t h25-Apr-07 1:06 
AnswerRe: How to print the items in a datagrid in ASP .Net Pin
Arun.Immanuel25-Apr-07 1:11
Arun.Immanuel25-Apr-07 1:11 
AnswerRe: How to print the items in a datagrid in ASP .Net Pin
Sathesh Sakthivel25-Apr-07 1:37
Sathesh Sakthivel25-Apr-07 1:37 
QuestionDeleting from a gridview control [modified] Pin
Senseicads25-Apr-07 0:11
Senseicads25-Apr-07 0:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.