This is a migrated thread and some comments may be shown as answers.

[Solved] Unable to bind the TextBox in the RadGridView when the RadGridView ViewState is disabled.

2 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jignesh
Top achievements
Rank 1
Jignesh asked on 15 Mar 2013, 12:05 AM
As I have a very large page,I decide to turn the viewstate off.
The problem I am facing now is that when I bind the Grid on PostBack,the TextBox retains the old value and it does not update to new value.
If I use a HTML input type text as shown below,then it binds correctly,but for ASP.Net TextBox it does not.(If the runat="server" attribute is present then it does not and if I remove that attribute it binds.)

For each items in the category I need to provide quantity,then save it and when I select a different category,the gridview will be build using the items of the selected category.So when I select a different category,the textboxes retains the value of previous items.

Does not bind:
<asp:TextBox ID="txtBoxQty" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.PhysicalWholeUnitsUsableOnHand")%>'
</asp:TextBox>

It does bind:
<input type="text" value='<%#DataBinder.Eval(Container, "DataItem.PhysicalQuantity")%>' />

Even,when I try to provide text in the ItemDataBound Event,it does not take the new value.
Even though,I have disabled the ViewState of the Grid,I am able to access the TextBox Control in the ItemDataBound Event.
I am using DataSet to bind the GridView. eg.gridView.DataSource=dataset;
I am posting all the value using javascript and WebService and then uisng __doPostBack to do a postback.

Kindly let me know if any additional information is required.
Also,kindly let me know how to make the above functionality work.

Thanks
Jignesh





2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 15 Mar 2013, 08:06 AM
Hello,

I have tried with below code snippet and its working fine for me.

<telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <asp:TextBox ID="txtBoxQty" runat="server" Text='<%# Eval("ID") %>'>
                           </asp:TextBox>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>

if still this thing is not worked for you then please provide code related to grid binding.

Thanks,
Jayesh Goyani
0
Jignesh
Top achievements
Rank 1
answered on 17 Mar 2013, 11:04 PM
Jayesh,

Thanks for the prompt reply.
It has nothing to do with the RadGrid,in the page there was piece of code related to SessionPageStatePersister
which was set to true.
Due to which, I was getting the above mentioned behaviour.
By setting it to false,everything seems to work correctly.

Thanks


Tags
Grid
Asked by
Jignesh
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Jignesh
Top achievements
Rank 1
Share this question
or