Click here to Skip to main content
15,388,820 members
Home / Discussions / C#
   

C#

 
GeneralRe: ClickOnce app launching separate executable being detected as a virus Pin
MichaelC#Noob26-Jul-16 10:44
professionalMichaelC#Noob26-Jul-16 10:44 
QuestionSending DropDownList Data Pin
MadDashCoder25-Jul-16 8:49
MemberMadDashCoder25-Jul-16 8:49 
QuestionShowing a custom balloon tip icon Pin
Member 1209073125-Jul-16 1:46
MemberMember 1209073125-Jul-16 1:46 
AnswerRe: Showing a custom balloon tip icon Pin
Curry Francis25-Jul-16 1:53
MemberCurry Francis25-Jul-16 1:53 
AnswerRe: Showing a custom balloon tip icon Pin
Ravi Bhavnani25-Jul-16 5:36
professionalRavi Bhavnani25-Jul-16 5:36 
QuestionLINQ Join Result Is Null Pin
MadDashCoder24-Jul-16 9:15
MemberMadDashCoder24-Jul-16 9:15 
AnswerRe: LINQ Join Result Is Null Pin
Mycroft Holmes24-Jul-16 14:30
professionalMycroft Holmes24-Jul-16 14:30 
GeneralRe: LINQ Join Result Is Null Pin
MadDashCoder24-Jul-16 18:24
MemberMadDashCoder24-Jul-16 18:24 
Hi thanks for replying. Below is my modified code which implements try catch.
C#
public Void MyMethod(string id)
{
 List<Product> _products = new List<Product>();
 List<Category> _categories = new List<Category>();
 
 _products = psc.FindAllProducts().ToList();//Returns a list of Products
 _categories = psc.FindAllCategories().ToList();//Returns a list of Categories
 
 ProductCategory selectedCategory = new ProductCategory();
 StringBuilder errors = new StringBuilder();
 
 try
 {
      var _productCategories = 
      from c in _categories join p in _products 
      on c.ID equals p.CategoryID 
      select new 
      {
         p.ID, p.Name, p.CategoryID, 
         _categoryID = c.ID, _categoryName = c.Name 
      };

      try
      {
        var selectedCat = _productCategories
        .Where(x => x._categoryID ==  Convert.ToInt32(id))
        .SingleOrDefault()._categoryName;
 
        foreach (var pc in _productCategories)
        {
          if (Convert.ToInt32(id) == pc.CategoryID)
          {
            selectedCategory.ProductID = pc.ID;
            selectedCategory.Name = pc.Name;
            selectedCategory.CategoryID = pc._categoryID;
            selectedCategory.CategoryName = pc._categoryName;
          }
        }                  
       }
       catch (Exception ex)
       {
           errors.Append(ex).AppendLine("<br> <br>");
       }
 }
 catch (Exception ex)
 {
    errors.Append(ex).AppendLine("<br"> <br>");
 } 
}


modified 25-Jul-16 1:02am.

AnswerRe: LINQ Join Result Is Null Pin
Richard Deeming24-Jul-16 22:31
mveRichard Deeming24-Jul-16 22:31 
GeneralRe: LINQ Join Result Is Null Pin
MadDashCoder25-Jul-16 4:51
MemberMadDashCoder25-Jul-16 4:51 
QuestionWhat is the correct code to invoke subscribers for an event? Pin
User 1106097923-Jul-16 21:16
MemberUser 1106097923-Jul-16 21:16 
AnswerRe: What is the correct code to invoke subscribers for an event? Pin
BillWoodruff23-Jul-16 21:31
mveBillWoodruff23-Jul-16 21:31 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
User 1106097923-Jul-16 21:54
MemberUser 1106097923-Jul-16 21:54 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
BillWoodruff23-Jul-16 22:03
mveBillWoodruff23-Jul-16 22:03 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
Richard MacCutchan24-Jul-16 1:31
mveRichard MacCutchan24-Jul-16 1:31 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
BillWoodruff24-Jul-16 2:59
mveBillWoodruff24-Jul-16 2:59 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
Richard MacCutchan24-Jul-16 4:28
mveRichard MacCutchan24-Jul-16 4:28 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
Richard Deeming24-Jul-16 22:15
mveRichard Deeming24-Jul-16 22:15 
AnswerRe: What is the correct code to invoke subscribers for an event? Pin
Pete O'Hanlon23-Jul-16 23:43
mvaPete O'Hanlon23-Jul-16 23:43 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
User 1106097923-Jul-16 23:53
MemberUser 1106097923-Jul-16 23:53 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
Pete O'Hanlon24-Jul-16 5:51
mvaPete O'Hanlon24-Jul-16 5:51 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
BillWoodruff24-Jul-16 23:04
mveBillWoodruff24-Jul-16 23:04 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
Richard Deeming25-Jul-16 0:05
mveRichard Deeming25-Jul-16 0:05 
GeneralRe: What is the correct code to invoke subscribers for an event? Pin
User 1106097925-Jul-16 0:30
MemberUser 1106097925-Jul-16 0:30 
SuggestionRe: What is the correct code to invoke subscribers for an event? Pin
Maarten197725-Jul-16 3:16
MemberMaarten197725-Jul-16 3:16 

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.