Reputation: 495
I have to load a large amount of data to a dynamic grid view. Grid view having link button created dynamically based on data. While clicking the link button, Inner Grid should be loaded. It is working fine.
But every time, on clicking the link button, on the Row bound event is fired, to bind the main grid.
With in the row bound event, inner grid is loading for each row in main grid , which is already clicked. i have maintain the clicked link button state(id field of the particular row) in Session, and using the session value , loading the inner grid on each row in main grid which is matched the session value in row bound event.
But loading takes long time. Is any other way to binding data to dynamic grid view on clicking the link button and maintain the clicked link button inner grid ?
My code is
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (strCallTypeName[intLoop].ToLower() != "total")
{
LinkButton lnk = new LinkButton();
lnk.Text = ((System.Data.DataRowView)(e.Row.DataItem)).Row[strCallTypeName[intLoop]].ToString();
lnk.CommandArgument = strCallTypeName[intLoop]
+ "|||"
+ ((System.Data.DataRowView)(e.Row.DataItem)).Row["UserId"].ToString()
+ "|||"
+ ((System.Data.DataRowView)(e.Row.DataItem)).Row["Service"].ToString()
+ "|||"
+ e.Row.RowIndex;
//lnk.Click += new EventHandler(lnk_Click);
//lnk.CommandName = "Edit";
lnk.Click += new EventHandler(lnk_Click);
lnk.ToolTip = strCallTypeName[intLoop];
lnk.CssClass = "lnk";
tc.Controls.Add(lnk);
string strUserID =grdSummaryCall.DataKeys[e.Row .RowIndex].Value.ToString();
string strSessionUserDetails = string.Empty;
strSessionUserDetails = (string)Session["GridUserDetails"];
if (strSessionUserDetails != string.Empty && strSessionUserDetails !=null)
{
string[] strSplitUserDetails = strSessionUserDetails.Split(new string[] { "~" }, StringSplitOptions.None);
Panel pnlTable = (Panel)e.Row.FindControl("pnlTable");
for (int i = 0; i < strSplitUserDetails.Length; i++)
{
string[] strUserDetails = strSplitUserDetails[i].Split(new string[] { "," }, StringSplitOptions.None);
if (strUserID == strUserDetails[1].ToString())
{
if (pnlTable.Visible == false)
{
GetUserCallDetails(strUserDetails, e.Row);
pnlTable.Visible = true;
}
}
}
}
}
}
Upvotes: 0
Views: 940
Reputation: 44605
Pooja, based on your comment above, I would make sure paging is working as expected and you are:
1 - only loading 30 records at time for the current page, not all of them and rendering only 30.
2 - NOT calling again the database layer for each row binding; You can load all details for every single row of the page at once (so no more than page size, in your case 30), when loading the data for the current page, so your database calls would go down to 1 per page not 1 + pagesize == 31 in your case.
Upvotes: 1