0
我有一個Datalist,並且正在使用左外連接作爲「領導」表,我正試圖獲得「位置」。但是我得到錯誤,「DataBinding:'System.Data.DataRowView'不包含名稱爲'Position'的屬性。」從2個sql server 2008表中填充數據列表,使用sqldatasource
CustomerTable LeadershipTable
CustomerId Name, LeadershipPosition Id Position
1 Bob 1 1 President
2 Greg 2 2 vice-President
3 Polly 4 3 Secratary
4 Anna 3 4 Treasurer
<asp:DataList ID="DataList1" RepeatColumns="2" DataKeyField="CustomerId" runat="server" DataSourceID="SqlDataSource2">
而且從代碼隱藏填充一個SqlDataSource:
SqlDataSource2.SelectCommand = "SELECT Customer.CustomerId, Customer.FName + ' ' + Customer.LName As Name, Customer.Address1, Customer.City, Customer.State, Customer.Zip, Customer.Cell, Customer.Email, Customer.profilePic, Customer.LeadershipPosition From Customer LEFT OUTER JOIN Leadership ON Customer.LeadershipPosition = Leadership.Id WHERE Customer.CommitteeId = '1'"
SqlDataSource2.DataBind()
如果你這樣做的話:Customer.LeadershipPositoin,Position(如果你在兩者之間插入逗號,我可以接受它作爲答案)。謝謝 – mlg74
你能接受答案..我編輯查詢 – Viji
你沒有編輯它的權利,但我會接受和張貼正確的代碼在這裏:SqlDataSource2.SelectCommand =「SELECT Customer.CustomerId,Customer.FName +''+ Customer。 LName作爲名稱,Customer.Address1,Customer.City,Customer.State,Customer.Zip,Customer.Cell,Customer.Email,Customer.profilePic,Customer.LeadershipPosition,客戶地位LEFT OUTER JOIN領導力Customer.LeadershipPosition =領導力。 Id WHERE Customer.CommitteeId =「&Request.QueryString(」Committee「)&」Order by Leadership.Id「 SqlDataSource2.DataBind() – mlg74