<asp:GridView ID="myGridView" runat="server" EmptyDataText="No Record Found" OnRowDataBound="myGridView_RowDataBound" Font-Size="Small" CssClass="Apartment_font_detail" GridLines="None" Width="100%" AllowPaging="True" PageSize="4" AutoGenerateColumns="False" OnPageIndexChanging="ShowPageCommand"> <Columns> <asp:TemplateField HeaderStyle-Wrap="true"> <ItemTemplate> <asp:Label ID="lblID" runat="server"></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderStyle-Wrap="true"> <ItemTemplate> <asp:Label ID="lblText" runat="server"></asp:Label> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView>
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindDataList(); } } private void BindDataList() { DataSet DS = new DataSet(); String strSQL; strSQL = "SELECT Car.* FROM Car"; strSQL += strPrice ; DS = clsDB.QueryDataSet(strSQL); clsDB.Close(); this.myGridView.DataSource = DS; this.myGridView.DataBind(); } protected void myGridView_RowDataBound(Object s, GridViewRowEventArgs e) { Label lblID= (Label )(e.Row.FindControl("lblID")); if (lblID!= null) { lblID.Text = DataBinder.Eval(e.Row.DataItem, "ID").ToString(); } Label lblText= (Label )(e.Row.FindControl("lblText")); if (lblText!= null) { lblText.Text = DataBinder.Eval(e.Row.DataItem, "Text").ToString(); } } protected void ShowPageCommand(Object s, GridViewPageEventArgs e) { myGridView.PageIndex = e.NewPageIndex; BindDataList(); } protected void txtPricePm1_Click(object sender, EventArgs e) { Price = " where price < 500000"; BindDataList(); }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง