【发布时间】:2012-05-16 13:33:18
【问题描述】:
实际上,说问题可能是错误的。我有 2 页。我可以从第一页获取第二页的查询字符串。这个查询字符串是我查询的关键部分。在调试模式下,我可以看到查询的结果,它们就是我想要的。但它不能显示在我的网格视图上。 这是我的代码块: 我的客户列表页面,
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的标记吗? -
如果我能看到,我会展示它.. 但正如我所说,我可以在调试模式下看到查询结果..
-
抱歉,我指的是
GridViewCustomerList的标记,因为它出现在您的 ASPX 页面(在 Visual Studio 中)。请在您的问题中添加那个。 -
没问题,但我想你还是误会了我 =) 在你的 ASPX 页面中,我想看到你的
GridView声明。它应该以这样的开头:<asp:GridView runat="server" ID="GridViewCustomerList">。然后使用edit 按钮将该内容添加到您的问题中。 -
我注意到我仍然误解你并在你之前删除我的评论 =) 好的。我加了。
标签: c# asp.net data-binding gridview page-lifecycle