Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
QuestionHow do I drag'n'drop components from the toolbox instead of writing code? Pin
arnold_w26-Jul-16 23:32
arnold_w26-Jul-16 23:32 
AnswerRe: How do I drag'n'drop components from the toolbox instead of writing code? Pin
OriginalGriff27-Jul-16 0:32
mveOriginalGriff27-Jul-16 0:32 
GeneralRe: How do I drag'n'drop components from the toolbox instead of writing code? Pin
arnold_w27-Jul-16 0:41
arnold_w27-Jul-16 0:41 
GeneralRe: How do I drag'n'drop components from the toolbox instead of writing code? Pin
OriginalGriff27-Jul-16 0:50
mveOriginalGriff27-Jul-16 0:50 
QuestionSystem.web.script.serialization not available to add in web api Pin
Raghavendra.Kodimala25-Jul-16 23:19
professionalRaghavendra.Kodimala25-Jul-16 23:19 
AnswerRe: System.web.script.serialization not available to add in web api Pin
Richard Deeming26-Jul-16 1:42
mveRichard Deeming26-Jul-16 1:42 
AnswerRe: System.web.script.serialization not available to add in web api Pin
F-ES Sitecore26-Jul-16 23:30
professionalF-ES Sitecore26-Jul-16 23:30 
Questionrandom wrong when in loop? Pin
Member 1243103925-Jul-16 20:48
Member 1243103925-Jul-16 20:48 
AnswerRe: random wrong when in loop? Pin
Richard MacCutchan25-Jul-16 21:00
mveRichard MacCutchan25-Jul-16 21:00 
AnswerRe: random wrong when in loop? Pin
Mehmet Coban29-Jul-16 5:50
Mehmet Coban29-Jul-16 5:50 
QuestionClickOnce app launching separate executable being detected as a virus Pin
MichaelC#Noob25-Jul-16 9:44
professionalMichaelC#Noob25-Jul-16 9:44 
AnswerRe: ClickOnce app launching separate executable being detected as a virus Pin
Dave Kreskowiak25-Jul-16 12:51
mveDave Kreskowiak25-Jul-16 12:51 
GeneralRe: ClickOnce app launching separate executable being detected as a virus Pin
MichaelC#Noob25-Jul-16 14:43
professionalMichaelC#Noob25-Jul-16 14:43 
GeneralRe: ClickOnce app launching separate executable being detected as a virus Pin
OriginalGriff25-Jul-16 19:04
mveOriginalGriff25-Jul-16 19:04 
GeneralRe: ClickOnce app launching separate executable being detected as a virus Pin
MichaelC#Noob26-Jul-16 10:39
professionalMichaelC#Noob26-Jul-16 10:39 
AnswerRe: ClickOnce app launching separate executable being detected as a virus Pin
Bernhard Hiller25-Jul-16 21:35
Bernhard Hiller25-Jul-16 21:35 
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
MadDashCoder25-Jul-16 8:49 
QuestionShowing a custom balloon tip icon Pin
Member 1209073125-Jul-16 1:46
Member 1209073125-Jul-16 1:46 
AnswerRe: Showing a custom balloon tip icon Pin
Curry Francis25-Jul-16 1:53
Curry 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
MadDashCoder24-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
MadDashCoder24-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 

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.