Hi friends,
I am entering children details like sr no, child name and age in a gridview. There is a button called ADD NEW in a footer. When I click on the button the new empty row gets added. I have set the allowpaging property to true and called the function on pageindexchanging. But when I go on second page and again come back on first all the data gets vanishes and empty row remains. Here I have set the page size to 5.
Any help would be appreciated
Thanks,
Vijay
Loading

Suthish NairPosted Feb 12, 2011, 2:24 PM
Or, use UpdatePanel might works.
Or, do not allow user to do paging during edit mode.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.pageindexchanging.aspx
Michael XiePosted Feb 12, 2011, 2:09 PM
Vijay YadavPosted Jan 23, 2011, 11:56 PM
I have used it... but then also its not working..
Thanks,
vijay
Suthish NairPosted Jan 21, 2011, 2:35 PM
Vijay YadavPosted Jan 21, 2011, 12:47 AM
I had tried this but it clears the gridview anyway..
Thanks,
Vijay
vijayPosted Jan 21, 2011, 12:38 AM
for page index changing try this code it really helpful to you.....
Protected Sub grdRemittance_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles grdRemittance.PageIndexChanging
grdRemittance.PageIndex = e.NewPageIndex
grdRemittance.DataBind()
End Sub
regards vijay
http://vbdotnetaddict.blogspot.com
Vijay YadavPosted Jan 20, 2011, 6:56 AM
public void children()
{
int num = 0;
dt = new DataTable();
dt.Columns.Add("SR_NO", typeof(string));
dt.Columns.Add("EMPLOYEE_CODE", typeof(string));
dt.Columns.Add("EMPLOYEE_NAME", typeof(string));
dt.Columns.Add("CHILD_NAME", typeof(string));
dt.Columns.Add("CHILD_AGE", typeof(string));
foreach (GridViewRow row in grvChildrenDetails.Rows)
{
DataRow dr;
dr = dt.NewRow();
dr["SR_NO"] = ((Label)row.FindControl("lblsr_no")).Text;
dr["CHILD_NAME"] = ((TextBox)row.FindControl("txtchildname")).Text;
dr["CHILD_AGE"] = ((TextBox)row.FindControl("txtchildage")).Text;
num =Convert.ToInt32(dr["SR_NO"]);
dt.Rows.Add(dr);
}
// dt = (DataTable)grvChildrenDetails.DataSource;
if (num > 4)
{
}
else
{
DataRow dr1 = dt.NewRow();
dt.Rows.Add(dr1);
//DataView dv = dt.DefaultView;
grvChildrenDetails.DataSource = dt;
grvChildrenDetails.DataBind();
}
}
this function i call on button click in footer to add new row
and on page index changing..
protected void grvChildrenDetails_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grvChildrenDetails.PageIndex = e.NewPageIndex;
children();// same function which i call on button click..
}
Any help would be appreciated.
Thanks,
Vijay
Blocked AccountPosted Jan 20, 2011, 6:17 AM
Can you post your code here. It would be fine to solve your problem.
Vijay YadavPosted Jan 20, 2011, 6:14 AM
@Manish i have binded that function but still it is not getting done and
@Jitendra not solved yet, if you know please tell me..
Thanks,
Vijay
Jiteendra SampathiraoPosted Jan 20, 2011, 6:08 AM
Is your problem solved? send me the code if not.
Blocked AccountPosted Jan 20, 2011, 6:05 AM
I think you are not binding the gridview in PageIndexchanging event.
try this