<asp:GridView ID="GridViewStudentsList" runat="server" AutoGenerateColumns="False" BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px" CellPadding="3" CellSpacing="1" EmptyDataText="No Details Found" GridLines="None" OnPageIndexChanging="GridViewStudentsList_PageIndexChanging" PagerStyle-Font-Bold="true" PagerStyle-ForeColor="#000066" PageSize="5" Style="z-index: 101; left: 60px; position: absolute; top: 80px"> <RowStyle BackColor="#DEDFDE" ForeColor="Black" /> <FooterStyle BackColor="#C6C3C6" ForeColor="Black" /> <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" /> <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" /> <HeaderStyle BackColor="#000066" Font-Bold="True" ForeColor="#E7E7FF" /> <Columns> <asp:BoundField DataField="Sno" HeaderText="Sno" /> <asp:BoundField DataField="RollNo" HeaderText="RollNo" /> <asp:BoundField DataField="Name" HeaderText="Name" /> <asp:BoundField DataField ="Department" HeaderText ="Department" /> <asp:BoundField DataField ="Year" HeaderText ="Year" /> </Columns> </asp:GridView>
protected void GridViewStudentsList_PageIndexChanging(object sender, GridViewPageEventArgs e) { try { GridViewStudentsList.PageIndex = e.NewPageIndex; FillStudentList(); } catch (Exception ex) { throw ex; } }
public void FillStudentList() { try { SqlAdapter = new SqlDataAdapter("select ''Sno,RollNo,Name,Department,StudentsAccounts.Year from StudentsAccounts inner join(select teacherid,Departmentid,dptName,year from TeachersWorkList inner join Departments on Departments.dptid=TeachersWorkList.departmentid Where Teacherid='" + HiddenFieldID.Value + "')As DptList On StudentsAccounts.Department=DptList.dptName And StudentsAccounts.Year=DptList.year where DptList.Departmentid='" + Session["MyDptID"].ToString() + "' And StudentsAccounts.Year='" + Session["Year"].ToString() + "' ", Connection); DataSet MyDataSetDetails = new DataSet(); SqlAdapter.Fill(MyDataSetDetails, "TeachersWorkList"); for (int i = 0; i <= MyDataSetDetails.Tables[0].Rows.Count - 1; i++) { MyDataSetDetails.Tables[0].Rows[i][0] = i + 1; } GridViewStudentsList.DataSource = MyDataSetDetails; GridViewStudentsList.DataBind(); } catch (Exception ex) { throw ex; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)