This question is locked. New answers and comments are not allowed.
Hi,
I experienced the following problem. I have a page with a server bound grid with some data fields, and a form with input controls which I would like to display values of the fields of a selected record for edit and next to submit. The names of these controls follow the names of the data fields (which are also the same as the columns of the grid). However when the page is displayed, input controls always are initialized with values of the last record displayed within the server side bound grid, regardless of what values these controls are set to display.
Here is a isolated code snippet:
If you run the above code snippet, controls for RecID and Data1 fields will display initially the values of the last record that is visible in the grid control, instead to display 2 and 5.
In the above snippet I use only Telerik's IntegerTextBox controls, but it my actual implementation (which is more complex) the same issue also was experienced when is used Telerik's DatePicker control and standard TextBox control from the System.Web.Mvc library (in that code sample I couldn't reproduce this behaviour with standard TextBox control).
Actually, I can change the names of the input controls to be not the same as the names of the data columns (data fields), and the problem will go away, but this will introduce a complexity later with automatic model binding when the form is submitted, i.e. need writing either of a custom ValueProvider or a custom ModelBinder.
Would you confirm if this is a bug, or is some limitation of using which need to be considered in implementations.
Kind regards
Todor Mihailov
I experienced the following problem. I have a page with a server bound grid with some data fields, and a form with input controls which I would like to display values of the fields of a selected record for edit and next to submit. The names of these controls follow the names of the data fields (which are also the same as the columns of the grid). However when the page is displayed, input controls always are initialized with values of the last record displayed within the server side bound grid, regardless of what values these controls are set to display.
Here is a isolated code snippet:
<
body
>
<% Html.Telerik().Grid((IEnumerable<
MyData
>)ViewData["Data"])
.Name("Grid")
.DataKeys(keys =>
keys.Add(key => key.RecID)
)
.Columns(cols => {
cols.Bound(col => col.RecID);
cols.Bound(col => col.Data1);
cols.Bound(col => col.Descr);
})
.Render();
%>
<% using(Html.BeginForm("SaveEditedData", "Home")) { %>
<
div
>
<
div
>
<%= Html.Telerik().IntegerTextBox()
.Name("RecID")
.Value(2)
.EmptyMessage(null)
%>
</
div
>
<
div
>
<%= Html.Telerik().IntegerTextBox()
.Name("Data1")
.Value(5)
.EmptyMessage(null)
%>
</
div
>
</
div
>
<% } %>
<% Html.Telerik().ScriptRegistrar()
.Render(); %>
</
body
>
If you run the above code snippet, controls for RecID and Data1 fields will display initially the values of the last record that is visible in the grid control, instead to display 2 and 5.
In the above snippet I use only Telerik's IntegerTextBox controls, but it my actual implementation (which is more complex) the same issue also was experienced when is used Telerik's DatePicker control and standard TextBox control from the System.Web.Mvc library (in that code sample I couldn't reproduce this behaviour with standard TextBox control).
Actually, I can change the names of the input controls to be not the same as the names of the data columns (data fields), and the problem will go away, but this will introduce a complexity later with automatic model binding when the form is submitted, i.e. need writing either of a custom ValueProvider or a custom ModelBinder.
Would you confirm if this is a bug, or is some limitation of using which need to be considered in implementations.
Kind regards
Todor Mihailov