Hi, I am Syed Fasih
---this is my aspx.cs file for the page navigation.
---this is my aspx file the gridview..
---this is the datafields of the Gridview.. We used the Linq Tables and filter it like this..
and my question is I tried the OnPageIndexChan ging programmaticall y but the page cant navigate to the other..
is the Page Navigation for Gridview are just working with has its DataSourceID property only?
Can the PageNavigation work with this Linq dataSource in aspx.cs file? thank you
---this is my aspx.cs file for the page navigation.
Code:
protected void grdConsultation_PageIndexChanging(object sender, GridViewPageEventArgs e) { grdConsultation.PageIndex = e.NewPageIndex; grdConsultation.DataBind(); }
---this is my aspx file the gridview..
Code:
<asp:GridView ID="grdConsultation" runat="server" AutoGenerateColumns="False" CellPadding="4" EmptyDataText="No result found." ForeColor="#333333" GridLines="None" Width="100%" onrowcommand="grdConsultation_RowCommand" PageSize="5" onrowdatabound="grdConsultation_RowDataBound" AllowPaging="True" onselectedindexchanged="grdConsultation_SelectedIndexChanged" OnPageIndexChanging="grdConsultation_PageIndexChanging"> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" /> <RowStyle BackColor="#F7F6F3" ForeColor="#333333" /> <Columns> <asp:CommandField ShowSelectButton="True"> <HeaderStyle CssClass="hidden" /> <ItemStyle CssClass="hidden" /> </asp:CommandField> <asp:BoundField DataField="Id" HeaderText="Id"> <HeaderStyle CssClass="hidden" /> <ItemStyle CssClass="hidden" /> </asp:BoundField> <asp:BoundField DataField="PatientId" HeaderText="Patient Id"> <HeaderStyle CssClass="hidden" /> <ItemStyle CssClass="hidden" /> </asp:BoundField> <asp:BoundField DataField="ConsultStart" DataFormatString="{0:MMM dd, yyyy}" HeaderText="Consultation Date"> </asp:BoundField> <asp:BoundField DataField="EmployeeId" HeaderText="ID Number" /> <asp:BoundField DataField="PatientName" HeaderText="Name" /> <asp:BoundField DataField="PatientType" HeaderText="Patient Type" /> <asp:BoundField DataField="Complaints" HeaderText="Complaints" /> <asp:BoundField DataField="Status" HeaderText="Status" /> <asp:ButtonField HeaderText="Action" Text="[Start Consultation]" CommandName="Start" /> </Columns> <PagerSettings Mode="NextPreviousFirstLast"/> <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Right" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" /> <EditRowStyle BackColor="#999999" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" /> </asp:GridView>
Code:
protected void btnSearch_Click(object sender, EventArgs e) { DateTime dtFrom = DateTime.MinValue; DateTime.TryParse(txtDateFrom.Text, out dtFrom); DateTime dtTo = DateTime.MinValue; DateTime.TryParse(txtDateTo.Text, out dtTo); int doctorId = 0; int.TryParse(ddlDoctor.SelectedValue, out doctorId); int branchId = 0; int.TryParse(ddlBranch.SelectedValue, out branchId); //rblSearchType.Select CIMSDataContext cims = new CIMSDataContext(); var cons = cims.Consultations.Where(c => (doctorId == 0 ? true : c.DoctorId == doctorId) && (dtFrom == DateTime.MinValue ? true : c.ConsultStart >= dtFrom) && (dtTo == DateTime.MinValue ? true : c.ConsultStart <= dtTo) && (string.IsNullOrEmpty(txtId.Text) ? true : c.Patient.EmployeeId == txtId.Text) && (string.IsNullOrEmpty(txtLastName.Text) ? true : c.Patient.LastName == txtLastName.Text) && (branchId == 0 ? true : c.BranchId == branchId) && (ddlConStatus.SelectedValue == "None" ? true : c.Status == ddlConStatus.SelectedValue) && (rblSearchType.SelectedValue == "All Patients" ? true : c.Patient.PatientType == rblSearchType.SelectedValue)); grdConsultation.DataSource = cons; grdConsultation.DataBind(); }
and my question is I tried the OnPageIndexChan ging programmaticall y but the page cant navigate to the other..
is the Page Navigation for Gridview are just working with has its DataSourceID property only?
Can the PageNavigation work with this Linq dataSource in aspx.cs file? thank you
Comment