Click here to Skip to main content
15,894,740 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionReturn List<> on button click of user control. Pin
zeego31-May-10 21:21
zeego31-May-10 21:21 
AnswerRe: Return List on button click of user control. Pin
Brij31-May-10 21:34
mentorBrij31-May-10 21:34 
GeneralRe: Return List on button click of user control. Pin
zeego31-May-10 21:49
zeego31-May-10 21:49 
GeneralRe: Return List on button click of user control. Pin
michaelschmitt31-May-10 22:45
michaelschmitt31-May-10 22:45 
GeneralRe: Return List on button click of user control. Pin
zeego31-May-10 23:06
zeego31-May-10 23:06 
GeneralRe: Return List on button click of user control. Pin
michaelschmitt1-Jun-10 0:27
michaelschmitt1-Jun-10 0:27 
GeneralRe: Return List on button click of user control Pin
zeego1-Jun-10 1:19
zeego1-Jun-10 1:19 
GeneralRe: Return List on button click of user control Pin
michaelschmitt1-Jun-10 2:30
michaelschmitt1-Jun-10 2:30 
If it is just about the collection you want to expose now, you
can either do this:

public ftExclusions GetSelectedExclusions() 
{ 
   ftExclusionsList myFTExclusionList = new ftExclusionsList(); 
   
   foreach (ListItem li in cblExclusions.Items) 
   { 
      if (li.Selected == true) 
      { 
         ftExclusions myftExclusion = new ftExclusions(); 
         myftExclusion.excluId = Convert.ToInt32(li.Value); 
         myftExclusion.excludesc = li.Text.ToString(); 
         myFTExclusionList.Add(myftExclusion); 
      } 
   }
   return myFTExclusionList;
}


or this (property):
public ftExclusionsList SelectedExclusions    
{        
   get { return GetSelectedExclusions(); }        
}

private ftExclusions GetSelectedExclusions() 
{ 
   ftExclusionsList myFTExclusionList = new ftExclusionsList(); 
   
   foreach (ListItem li in cblExclusions.Items) 
   { 
      if (li.Selected == true) 
      { 
          ftExclusions myftExclusion = new ftExclusions(); 
          myftExclusion.excluId = Convert.ToInt32(li.Value); 
          myftExclusion.excludesc = li.Text.ToString(); 
          myFTExclusionList.Add(myftExclusion); 
      } 
   }
   return myFTExclusionList;
}


Then use the property OR method in the desired event of your page. This is all assuming that the rest of the code works.

A hint: Check for null before checking the count of a collection. Otherwise, you could get an exception. It is also usefull to check like

if (null==something) 

// instead of
if (something == null)


This way, you can prevent typing mistakes like If (something = null)...

GL

GL
AnswerRe: Return List on button click of user control. Pin
Andreas X1-Jun-10 1:28
professionalAndreas X1-Jun-10 1:28 
Questiontext in windows service appears to have old reference Pin
Member 391904931-May-10 21:16
Member 391904931-May-10 21:16 
AnswerRe: text in windows service appears to have old reference Pin
Sandeep Mewara31-May-10 23:56
mveSandeep Mewara31-May-10 23:56 
GeneralRe: text in windows service appears to have old reference Pin
Member 39190491-Jun-10 5:53
Member 39190491-Jun-10 5:53 
AnswerRe: text in windows service appears to have old reference Pin
aashish.saalvi1-Jun-10 1:53
aashish.saalvi1-Jun-10 1:53 
QuestionDataView Pin
Satish_S31-May-10 20:58
Satish_S31-May-10 20:58 
AnswerRe: DataView Pin
Sandeep Mewara31-May-10 23:58
mveSandeep Mewara31-May-10 23:58 
Questiontrying to get windows service to auto-start after install Pin
Member 391904931-May-10 19:25
Member 391904931-May-10 19:25 
AnswerRe: trying to get windows service to auto-start after install Pin
Sandeep Mewara31-May-10 19:44
mveSandeep Mewara31-May-10 19:44 
Questionasp table with javascript getelementbyid Pin
Aljaz11131-May-10 14:53
Aljaz11131-May-10 14:53 
AnswerRe: asp table with javascript getelementbyid Pin
Sandeep Mewara31-May-10 19:17
mveSandeep Mewara31-May-10 19:17 
AnswerRe: asp table with javascript getelementbyid Pin
Amit M patel31-May-10 20:59
Amit M patel31-May-10 20:59 
GeneralRe: asp table with javascript getelementbyid Pin
Aljaz1111-Jun-10 3:33
Aljaz1111-Jun-10 3:33 
QuestionRun Web Application Under Evaluation Period. Pin
VikashGohil31-May-10 7:34
VikashGohil31-May-10 7:34 
AnswerRe: Run Web Application Under Evaluation Period. Pin
Brij31-May-10 9:38
mentorBrij31-May-10 9:38 
GeneralRe: Run Web Application Under Evaluation Period. Pin
VikashGohil31-May-10 20:10
VikashGohil31-May-10 20:10 
GeneralRe: Run Web Application Under Evaluation Period. Pin
Brij31-May-10 21:05
mentorBrij31-May-10 21:05 

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.