Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am binding some records to gridview, the binding process is done correctly and also iam adding commandfield for editing and deleting. When i am editing first time all the cell value go to the corresponding textboxes or other controls, editing is worked perfectly. But the problem is that when i am editing another record in the gridview the row become textboxes like template field.Please help me.I think this is an unexpected behaviour.


Look at the screenshot you get what is my pblm

http://bit.ly/eg1YnS[^]

http://bit.ly/fEdKOQ[^]

Update:
C#
public bool Bind(string Query, GridView grdView) 
{
 sqlFunc = new DB.SQLFunctions();
 DataTable dTable = sqlFunc.ReturnDataTable(Query);
 grdView.DataSource = dTable;
 grdView.DataBind();
 return true;
 }


This is the method iam just calling this method and bind.iam doing so many times this approach.but this pblm i can't fix
Posted
Updated 29-Mar-11 1:04am
v2
Comments
Venkatesh Mookkan 29-Mar-11 6:36am    
Post your binding logic.
Jameel VM 29-Mar-11 6:52am    
public bool Bind(string Query, GridView grdView)
{
sqlFunc = new DB.SQLFunctions();
DataTable dTable = sqlFunc.ReturnDataTable(Query);
grdView.DataSource = dTable;
grdView.DataBind();
return true;
}
this is the method iam just calling this method and bind.iam doing so many times this approach.but this pblm i can't fix

From the above scenario only thing I can guess is that you are calling the Bind() method from Page_Load event handler without checking IsPostback property.

If you call Bind() method from Page_Load, try like

C#
if (!IsPostback)
{
    //YOUR CODE GOES HERE
    //
    Binding(YOUR_QUERY, gridView);
}
 
Share this answer
 
Comments
Jameel VM 29-Mar-11 8:01am    
In VS 2008 there is no pblm.In 2010 the gridview behavior is changed while editing
Venkatesh Mookkan 29-Mar-11 8:28am    
In that case, zip your sample code, upload in dropbox or something and give URL. I will check and let you know.
Jameel VM 29-Mar-11 8:39am    
I think this is not a pblm in code.It's work .net 3.5 gridview.but in 4.0 the gridview become like second screen shot.I send u the code to your mail id.please send your mail id
Venkatesh Mookkan 29-Mar-11 8:56am    
Upload somewhere like dropbox.com or skydrive.live.com and provide URL. I will take it from there.
Jameel VM 29-Mar-11 8:39am    
I think this is not a pblm in code.It's .net 3.5 gridview.but in 4.0 the gridview become like second screen shot.I send u the code to your mail id.please send your mail id
if page is load then data is display successfully in page. you click the update or reset button, all work complete then you page is transfer or redirect to same page.
 
Share this answer
 
Comments
Jameel VM 29-Mar-11 8:00am    
In 2008 it's working.pblm is in 2010
Jameel VM 29-Mar-11 8:51am    
When redirecting the page the all the value while editing is become empty.'its not a good way.why this pblm is only in .net 4.0?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900