【发布时间】:2014-08-15 13:56:45
【问题描述】:
只是为了澄清一下,让我的标题有意义:我在我的数据库中测试了我的查询,它确实有效,所有数据都显示了。当我把它放在 gridview 中时,它不会填充最后一个字段。我不确定是不是因为有两个数据字段被称为“笔记”,或者我只是遗漏了一些东西,一遍又一遍地阅读它并没有帮助。
这是我的查询(我不擅长格式化):
cmd.CommandText =
@"SELECT c.customer_id, c.customer_name, c.product_mgr, p.license_start_date, p.version,
pd.processor, pd.notes, ci.f_name, ci.l_name, ci.phone, ci.email,
ci.title, ci.notes FROM Customer c LEFT OUTER JOIN " + p + @" p ON c.customer_id = p.customer_id
LEFT OUTER JOIN " + p + @"Details pd ON p.customer_id = pd.customer_id
LEFT OUTER JOIN ContactInfo ci ON c.customer_id = ci.customer_id ORDER BY customer_id";
这是我的网格视图:
<asp:GridView id="gvProd" runat="server" EnableViewState="true" AutoGenerateColumns="false">
<Columns>
<asp:boundfield datafield="customer_id" headertext="Customer ID" />
<asp:boundfield datafield="customer_name" headertext="Customer Name" />
<asp:BoundField DataField="product_mgr" HeaderText="Product Mgr" />
<asp:BoundField DataField="license_start_date" HeaderText="Start Date" DataFormatString="{0:d}" />
<asp:BoundField DataField="version" headertext="Product Version" />
<asp:BoundField DataField="processor" HeaderText="Payment Processor" />
<asp:BoundField DataField="notes" HeaderText="Product Notes" />
<asp:BoundField DataField="f_name" HeaderText="First Name" />
<asp:BoundField DataField="l_name" HeaderText="Last Name" />
<asp:BoundField DataField="phone" HeaderText="Phone" />
<asp:BoundField DataField="email" HeaderText="Email" />
<asp:BoundField DataField="title" HeaderText="Position/Title" />
<asp:BoundField DataField="notes" HeaderText="Contact Notes" />
</Columns>
</asp:GridView>
该死,我认为最重要的部分我忽略了。第二个注释字段未填写。我知道里面有数据。但是其他联系人的东西已经填满了,所以我知道那是有效的
【问题讨论】: