Based on what you've posted so far, there is no exception possible. But, since we can't see the code that declared these types, the details collection, how it's populated, ..., we really couldn't tell you for sure.
But, if the Select returns no ID's, the array will come back empty and the foreach iterating over it won't do anything.
You don't have to change this code at all.
Next time, you might want to try testing the code with test data specifically designed to try and break it.
string PkgIDs = rData.details.Where(c => c.batch_id == batchID).Select(c => c.Package_ID).Distinct().ToArray();
if(PkgIDs.Count > 0)//This will check the number of elements in the List
foreach (string PkgID in PkgIDs)
In C#, How To Send A Hyperlink Using Query String Method.
I have developing a web application of user enter enters the personal data. That information has sent to admin mail with approve/reject link button.
When the Admin click the approve link, it has approve.aspx page with the user id as query string to update the db as approved. otherwise rejected.
I can try the following code.
mail.Subject = "New User";
mail.Body = "<p>Dear Sir, <br><br> " + txtfname.Text + " " + txtlname.Text + ", has raised a requisition that needs your approval. <br><br><br> Please click to [<ahref='http://localhost:1240/IMA/Approve.aspx?id="+tt+"'> Approve</a> ] [<ahref='Reject.aspx'>Reject</a> ] the request. <br><br><br><b>Note</b> : Please do not reply. This e-mail has been auto-generated.</p>";
mail.IsBodyHtml = true;
In the mail i have move the mouse over the approve link it shows http://.../approve.aspx?id=1, but click the appove link
it shows <a href="http://.../id=1.
For a C# 2010 application, I need to check for the values in a column being all spaces. The number of space characters in a field can change. Thus can you tell me how to tell if a field in a string and/or a datadbase column is all spaces?
I was thinking about a software that can send messages without connecting any phone to your computer. You just have to register your number and than receiver's number and message will be send using your GSM services. If you know what i mean. It will use your phone's credit there is no role of phone physically. I am thinking about using c#. Help if someone can help me.
Last Visit: 31-Dec-99 18:00 Last Update: 24-Sep-23 5:10