I am a little stuck on how to achieve the following.
What I want to do is loop through some information in the database via Linq to SQL and display the looped information. In my example the query would bring back two sets of results, therefore I would like it to display both sets of information.
In the code behind I have...
protected void Page_Load(object sender, EventArgs e)
{
Partner_References();
}
protected void Partner_References()
{
var UserVar = HttpContext.Current.Items["UserInfo"] as UserInfo;
DCDataContext dc = new DCDataContext();
var PartnerRef = from p in dc.CS_Partnership_References where p.Partner_DNNUserID == UserVar.UserID select p;
foreach (var pr in PartnerRef)
{
Reference_ClientName.Text = pr.Reference_ClientName;
Reference_ClientName.ID = "Reference_ClientName_" + pr.Reference_ID + "";
Reference_Content.Text = pr.Reference_Content;
Reference_Content.ID = "Reference_Content_" + pr.Reference_ID + "";
Reference_WebsiteImage.Text = pr.Reference_WebsiteImage;
Reference_WebsiteImage.ID = "Reference_WebsiteImage_" + pr.Reference_ID + "";
Reference_WebsiteURL.Text = pr.Reference_WebsiteURL;
Reference_WebsiteURL.ID = "Reference_WebsiteURL_" + pr.Reference_ID + "";
}
}
In the front end .ascx I have...
No my question is, how would I display both the results in the front end .ascx, with the ID's of the TextBox's changing based on the Reference_ID.
This is working fine bringing back the last result but how would I get it to display both like below?
Many thanks,
Dane
Javeed M ShaikhPosted Oct 10, 2011, 4:53 AM
Following article explains how to use Multiple results LINQ to SQL:
http://blogs.msdn.com/b/swiss_dpe_team/archive/2008/02/04/linq-to-sql-returning-multiple-result-sets.aspx
Please do not forget to mark "Accepted Answer"
Suthish NairPosted Oct 10, 2011, 2:57 PM
Dane MarshallPosted Oct 10, 2011, 6:58 AM
Im not sure that post helps.
Dane