當數據綁定到gridview時我沒有得到任何東西。誰能幫忙?沒有從數據庫中獲取數據到gridview
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="1000px" AllowPaging="True" PageSize="8" `CssClass="Grid" AlternatingRowStyle-CssClass="alt" PagerStyle-CssClass="pgr">
<AlternatingRowStyle CssClass="alt"></AlternatingRowStyle>
<PagerStyle CssClass="pgr"></PagerStyle>
</asp:GridView>
C#
SqlCommand cmd1 = new SqlCommand("SELECT cars.carid, cars.make, cars.model, cars.condition, cars.amount, img.img FROM cars INNER JOIN img ON cars.carid = img.imgid where model = '" + mod + "' and make = '" + mak + "' and variant = '" + var + "' and color = '" + col + "' and condition = '" + cond + "'",con);
SqlDataAdapter sda1 = new SqlDataAdapter(cmd1);
DataTable dt = new DataTable();
sda1.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
是否有錯誤?你看到dt中的數據了嗎? – Sajeetharan
沒有錯誤..空白頁面顯示 – Samsam