Hi there,
I'd like to apologise in advance if I am repeating a question someone else has asked or if it's a really stupid question! - but I have been searching the forums for ages and can't find a clear answer!
I have installed netTiers on by asp.net/c# website and been using the basics without too many problems - but I have a simple request - I have a page where I would like to list my company profile using a DataList - now I can easily do this with using sql - but that's not really the point is it! Can someone tell me - please - where I am going wrong trying to bind a some data to the datasource!
Here is my code:
(page)
<asp:DataList ID="dlProfile" runat="server" Visible="true" RepeatColumns="2">
<HeaderTemplate>Your Profile</HeaderTemplate>
<ItemTemplate>
Company Name: <%# Eval("companyName")%><br />
Address 1: <%# Eval("address1")%><br />
Address 2: <%# Eval("address2")%><br />
Address 3: <%# Eval("address3")%><br />
Postcode: <%# Eval("postcode")%><br />
Phone: <%# Eval("phone")%><br />
Fax: <%# Eval("fax")%><br />
Mobile: <%# Eval("mobile")%><br />
Email: <%# Eval("companyEmail")%><br />
Logo: <%# Eval("companyLogo")%><br />
Promo Email: <%# Eval("promoEmail")%><br />
</ItemTemplate>
</asp:DataList><br />
Now I have tried to bind the data a few ways (with no success!)
By adding a Datasource:
top Line changed:
<asp:DataList ID="dlProfile" runat="server" Visible="true" RepeatColumns="2" DataSourceID="companyDataSourceStuff" DataKeyField="PkCompanyId" >
<data:CompanyDataSource ID="companyDataSourceStuff" SelectMethod="GetByPkCompanyId" runat="server">
</data:CompanyDataSource>
Code Behind:
companyDataSourceStuff.Parameters.Add("PkCompanyId",(string)Session["CompanyId"]);
Which dosn't error - but also dosn't bring up the data!
2nd way: (code behind)
Company CurrentCompany = new Company();
CompanyService CurrentCompanyService = new CompanyService();
CurrentCompany = CurrentCompanyService.GetByPkCompanyId(CurrentCompanyID);
dlProfile.DataSource = CurrentCompany;
dlProfile.DataBind();
Which dosn't work as it can't loop through the data!
3rd way: (code behind)
TList<Company> companyCollection = DataRepository.CompanyProvider.GetByPkCompanyId(CurrentCompanyID);
DataRepository.CompanyProvider.DeepLoad(companyCollection);
dlProfile.DataSource = companyCollection;
dlProfile.DataBind();
Which was a total stab in the dark
Any help would be appreciated!
:o)
Cassandra