Lbl_Username.Text = FirstName + " " + LastName; if (!IsPostBack) { ds = objSun.FetchTravelDetails(userId); int datasetcount = ds.Tables[0].Rows.Count; if (datasetcount == 0) { dt.Columns.Add("request_ID"); dt.Columns.Add("userId"); dt.Columns.Add(""); dt.Columns.Add("status"); dt.Columns.Add("remark"); dt.Columns.Add(""); for (int i = 0; i < 9; i++) { DataRow dr = dt.NewRow(); dt.Rows.Add(dr); } GridView_RequisitionManagement.DataSource = dt; GridView_RequisitionManagement.DataBind(); } else { GridView_RequisitionManagement.DataSource = ds; GridView_RequisitionManagement.DataBind(); } } }
protected void GridView_RequisitionManagement_RowDataBound(object sender, GridViewRowEventArgs e)
{
int datasetcount1 = ds.Tables[0].Rows.Count;
if (datasetcount1 != 0)
{
for (int i = 0; i < GridView_RequisitionManagement.Rows.Count; i++)
{
LinkButton lnk_view = new LinkButton();
lnk_view = GridView_RequisitionManagement.Rows[i].FindControl("LinkBtn_ViewFullDetails_GridView_LeaveManagement") as LinkButton;
int type = Convert.ToInt32(ds.Tables[0].Rows[i]["request_Type"].ToString());
string typeName = "";
string requestId = GridView_RequisitionManagement.DataKeys[i][0].ToString();
string request_userId = GridView_RequisitionManagement.DataKeys[i][1].ToString();
switch (type)
{
case 2:
{
typeName = "Travel Request";
lnk_view.PostBackUrl = "Status_ViewDetails_TravelClaims.aspx?requestId=" + requestId;
break;
}
case 3:
{
typeName = "Other Claims";
lnk_view.PostBackUrl = "Status_ViewDetails_OtherClaims.aspx?requestId=" + requestId;
break;
}
case 4:
{
typeName = "Petty cash";
lnk_view.PostBackUrl = "Status_ViewDetails_PettyCashVoucher.aspx?requestId=" + requestId;
break;
}
case 5:
{
typeName = "Advance";
lnk_view.PostBackUrl = "Status_ViewDetails_AdvanceRequisitions.aspx?requestId=" + requestId;
break;
}
}
GridView_RequisitionManagement.Rows[i].Cells[1].Text = Convert.ToDateTime(ds.Tables[0].Rows[i]["date"].ToString()).ToShortDateString();
GridView_RequisitionManagement.Rows[i].Cells[2].Text = typeName;
}
}
else
{
for (int j = 0; j < GridView_RequisitionManagement.Rows.Count; j++)
{
GridViewRow rows = GridView_RequisitionManagement.Rows[j];
LinkButton lnk_grd_views = (LinkButton)rows.FindControl("LinkBtn_ViewFullDetails_GridView_LeaveManagement") as LinkButton;
lnk_grd_views.Visible = false;
}
}
}
protected void GridView_RequisitionManagement_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView_RequisitionManagement.PageIndex = e.NewPageIndex;
GridView_RequisitionManagement.DataSource = ds;
GridView_RequisitionManagement.DataBind();
}
hi guys, i need some help here. im using the above code to display the details in the gridview.the datatable and dataset are used to display here. now i want to do page indexing in the grid here. when the next page is clicked here it shows an error that .."The IListSource does not contain any data sources" and the next page in the grid shows empty.
pls somebody help here.