Click here to Skip to main content
15,922,894 members
Home / Discussions / C#
   

C#

 
QuestionDatagrid Checkbox is not getting binded to dataset/ access database Pin
jeweladdict2-Jan-09 12:28
jeweladdict2-Jan-09 12:28 
AnswerRe: Datagrid Checkbox is not getting binded to dataset/ access database Pin
jeweladdict2-Jan-09 12:40
jeweladdict2-Jan-09 12:40 
GeneralRe: Datagrid Checkbox is not getting binded to dataset/ access database Pin
jeweladdict2-Jan-09 12:53
jeweladdict2-Jan-09 12:53 
Questionclose the runing process Pin
abu rakan2-Jan-09 11:44
abu rakan2-Jan-09 11:44 
QuestionRe: close the runing process Pin
Mark Salsbery2-Jan-09 11:55
Mark Salsbery2-Jan-09 11:55 
AnswerRe: close the runing process Pin
User 66582-Jan-09 11:57
User 66582-Jan-09 11:57 
AnswerRe: close the runing process Pin
Dave Kreskowiak2-Jan-09 19:52
mveDave Kreskowiak2-Jan-09 19:52 
Questionhelp...................... Pin
abu rakan2-Jan-09 11:39
abu rakan2-Jan-09 11:39 
AnswerRe: help...................... Pin
Mark Salsbery2-Jan-09 11:58
Mark Salsbery2-Jan-09 11:58 
GeneralRe: help...................... Pin
CPallini3-Jan-09 2:54
mveCPallini3-Jan-09 2:54 
GeneralRe: help...................... Pin
Eddy Vluggen3-Jan-09 23:19
professionalEddy Vluggen3-Jan-09 23:19 
AnswerRe: help...................... Pin
Dave Kreskowiak2-Jan-09 19:51
mveDave Kreskowiak2-Jan-09 19:51 
AnswerRe: help...................... Pin
#realJSOP2-Jan-09 23:58
professional#realJSOP2-Jan-09 23:58 
Questionsound in c# Pin
BESHOY MARKO2-Jan-09 10:50
BESHOY MARKO2-Jan-09 10:50 
AnswerRe: sound in c# Pin
Kristian Sixhøj2-Jan-09 10:53
Kristian Sixhøj2-Jan-09 10:53 
GeneralRe: sound in c# Pin
BESHOY MARKO2-Jan-09 11:06
BESHOY MARKO2-Jan-09 11:06 
GeneralRe: sound in c# Pin
Kristian Sixhøj2-Jan-09 23:58
Kristian Sixhøj2-Jan-09 23:58 
GeneralRe: sound in c# Pin
CPallini3-Jan-09 2:58
mveCPallini3-Jan-09 2:58 
QuestionRetrieving data from the last line in a text file Pin
soulg772-Jan-09 7:35
soulg772-Jan-09 7:35 
GeneralRe: Retrieving data from the last line in a text file Pin
Luc Pattyn2-Jan-09 8:04
sitebuilderLuc Pattyn2-Jan-09 8:04 
AnswerRe: Retrieving data from the last line in a text file Pin
#realJSOP2-Jan-09 8:25
professional#realJSOP2-Jan-09 8:25 
Questionpassing a value from one method to another method without calling the method, infact no relation exists between two methods, just value is needed. Pin
suni_dotnet2-Jan-09 6:15
suni_dotnet2-Jan-09 6:15 
AnswerRe: passing a value from one method to another method without calling the method, infact no relation exists between two methods, just value is needed. Pin
Colin Angus Mackay2-Jan-09 7:07
Colin Angus Mackay2-Jan-09 7:07 
Questionmy senario Pin
suni_dotnet2-Jan-09 8:41
suni_dotnet2-Jan-09 8:41 
AnswerRe: my senario Pin
Colin Angus Mackay2-Jan-09 12:42
Colin Angus Mackay2-Jan-09 12:42 
suni_dotnet wrote:
fields are not working properly.


I don't see any evidence from this code that you have a field at all.

Here is your code re-written:

class MyForm
{ 
  private string resbutton; // This is the field
 
  protected void Button1_Click(object sender, EventArgs e)
  {
    resbutton = "abcMenu";
    // .....
  }
 
  protected void Button2_Click(object sender, EventArgs e)
  {
    resbutton = "defMenu";
    // .....
  }
 
  protected void Button3_Click(object sender, EventArgs e)
  {
    resbutton = "jklMenu";
    // .....
  }
 
  protected void Button4_Click(object sender, EventArgs e)
  {
    switch(resbutton)
    {
      case "abcMenu":
        // Do stuff based on Button1 being pressed
        break;
      case "defMenu":
        // Do stuff based on Button2 being pressed
        break;
      case "jklMenu":
        // Do stuff based on Button3 being pressed
        break;
      default:
        // Do suff based on none of the buttons being pressed
        break;
    }
  }
}


Of course there may be better ways of doing this, but since we don't know what your actual overall goal is we can't say. Christian's suggestion of using delegates has merit also.

I'd also suggest using something other than a string for the field. Creating a specific enum that enumerates each type of button would be good.


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.