其實,說問題可能是錯誤的。我有2頁。我可以從第一頁的第二頁獲取查詢字符串。而這個查詢字符串是我查詢的關鍵部分。當調試模式,我可以看到查詢的結果,他們將是我想要的。但它不能顯示在我的GridView上。 這裏是我的代碼塊: 我CustomerList頁,datagridview數據綁定的問題
public partial class CustomerList : System.Web.UI.Page
{
CustomerBusiness m_CustomerBusiness = new CustomerBusiness();
COMPANY m_Company = new COMPANY();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
BindCustomers();
}
}
private void BindCustomers()
{
string CompanyName = Request.QueryString.Get("CompanyName");
LabelCompanyName.Text = CompanyName;
List<CUSTOMER> CustomerListt = m_CustomerBusiness.SelectByFirmName(CompanyName);
GridViewCustomerList.DataSource = CustomerListt;
GridViewCustomerList.DataBind();
}
}
GridViewCustomerList:
<asp:GridView ID="GridViewCustomerList" runat="server"
AutoGenerateColumns="False" BackColor="White" BorderColor="#999999"
BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical"
ondatabinding="GridViewCustomerList_DataBinding"
onselectedindexchanged="GridViewCustomerList_SelectedIndexChanged"
Width="239px">
<AlternatingRowStyle BackColor="#DCDCDC" />
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F1F1F1" />
<SortedAscendingHeaderStyle BackColor="#0000A9" />
<SortedDescendingCellStyle BackColor="#CAC9C9" />
<SortedDescendingHeaderStyle BackColor="#000065" />
</asp:GridView>
CustomerList是我想要的,但我的綁定部分不工作,當我我不能看到GridViewCustomerList運行該項目。我研究了一些asp.net頁面生命週期模型,目標解決方案可能與此有關。
你可以爲你的'GridView'顯示標記嗎? – jadarnel27
如果我能看到它,我會顯示它..卜t正如我所說,我可以看到在調試模式下查詢的結果。 – yiddow
對不起,我指的是'GridViewCustomerList'的標記,因爲它出現在你的ASPX頁面上(在Visual Studio中)。請在您的問題中添加*。 – jadarnel27