ASPX file code
-------------------
<asp:GridView ID="grdCourseDetails" runat="server" CssClass="table table-responsive"
AutoGenerateColumns="False"
EmptyDataText="No Records Found!" ShowHeaderWhenEmpty="True"
AllowPaging="True" PagerSettings-PageButtonCount="10" PagerSettings-Mode="Numeric"
PageSize="10" CellPadding="4" onpageindexchanging="grdCourseDetails_PageIndexChanging"
ForeColor="#333333" GridLines="None" Width="100%">
<Columns>
<asp:TemplateField HeaderText="Sl.No">
<ItemTemplate>
<%#(grdCourseDetails.PageSize * grdCourseDetails.PageIndex) + (Container.DisplayIndex + 1)%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Course_Name" NullDisplayText="N/A" HeaderText="Course Name"/>
<asp:BoundField DataField="Requested_Date" NullDisplayText="N/A" DataFormatString="{0:dd/MM/yyyy}" HeaderText="Requested Date"/>
<asp:BoundField DataField="Approval_Date" NullDisplayText="N/A" DataFormatString="{0:dd/MM/yyyy}" HeaderText="Approval Date"/>
<asp:BoundField DataField="Remark" NullDisplayText="N/A" HeaderText="Remarks"/>
<asp:BoundField DataField="Req_Status" NullDisplayText="N/A" HeaderText="Status"/>
</Columns>
<EditRowStyle BackColor="#4AAD44" />
<FooterStyle BackColor="#4AAD44" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#4AAD44" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#4AAD44" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
------------------------------
protected void Page_Load(object sender, EventArgs e)
{
GetCourseDetails(0);
}
protected void GetCourseDetails(Int16 Status)
{
DataTable dt;
string UserQuery = @"select * from VW_GetCourseDetails where CA_ID =@CA_ID and
Status=CASE WHEN @status=1 THEN 1 when @status=2 then 2 when @status=3 then 3 else Status end";
dt = Luminious.DataAcessLayer.SqlHelper.ExecuteDataTable(Luminious.Connection.Configuration.ConnectionString, CommandType.Text, UserQuery,
new SqlParameter[] {
new SqlParameter("@CA_ID", Session["CAId"] != null ? Convert.ToString(Session["CAId"] ) : null),
new SqlParameter("@Status", Status)
});
if (dt != null && dt.Rows.Count > 0)
{
grdCourseDetails.DataSource = dt;
grdCourseDetails.DataBind();
}
else
{
grdCourseDetails.DataSource = null;
grdCourseDetails.DataBind();
}
}
protected void grdCourseDetails_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdCourseDetails.PageIndex = e.NewPageIndex;
GetCourseDetails(Convert.ToInt16(Lbl_Course_Div_Status.Text));
}
this.CourseTotal.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(this.CourseTotal, string.Empty));
if (IsPostBack && Request["__EVENTTARGET"] == CourseTotal.UniqueID)
{
Lbl_Course_Div_Status.Text = "";
CourseTotal_Click(CourseTotal, EventArgs.Empty);
Lbl_Course_Div_Status.Text = "0";
}
protected void CourseTotal_Click(object sender, EventArgs e)
{
grdCourseDetails.PageIndex = 0;
GetCourseDetails(0);
}
No comments:
Post a Comment