Hi,
I have searched high and low for a solution to this problem, but haven't been able to find answer as yet.
I am trying to fix a bug in an existing application. There is a grid with a column of text-boxes that the user can enter data into. The column is made editable in the grid PreRender event.
Here is the code:
Running the code shows the editable column correctly, however changing the page size doesn't work as expected. Paging however seems to work fine.
If I comment out TGrid.Rebind();, or
Thanks in advance.
I have searched high and low for a solution to this problem, but haven't been able to find answer as yet.
I am trying to fix a bug in an existing application. There is a grid with a column of text-boxes that the user can enter data into. The column is made editable in the grid PreRender event.
Here is the code:
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
>
</
asp:ScriptManager
>
<
div
>
<
telerik:RadGrid
ID
=
"TGrid"
runat
=
"server"
Visible
=
"true"
AllowPaging
=
"true"
AllowSorting
=
"true"
PageSize
=
"20"
ScrollHeight
=
"100px"
ViewStateMode
=
"Enabled"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
OnPreRender
=
"RadGrid1_PreRender"
AutoGenerateColumns
=
"false"
AllowSelection
=
"False"
AllowMultiRowSelection
=
"false"
AllowMultiRowEdit
=
"true"
>
<
MasterTableView
runat
=
"server"
HeaderStyle-Wrap
=
"False"
AllowCustomSorting
=
"true"
AllowMultiColumnSorting
=
"false"
RetrieveAllDataFields
=
"false"
EnableColumnsViewState
=
"false"
EditFormSettings-EditColumn-Visible
=
"false"
AdditionalDataFieldNames
=
"Cow_ID"
DataKeyNames
=
"Cow_ID"
EditMode
=
"InPlace"
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"Cow_ID"
HeaderText
=
"MiHub ID"
DataType
=
"System.Int32"
ReadOnly
=
"true"
HeaderStyle-Width
=
"6em"
/>
<
telerik:GridBoundColumn
DataField
=
"COW_EID"
HeaderText
=
"Electronic ID"
DataType
=
"System.String"
ReadOnly
=
"true"
HeaderStyle-Width
=
"12em"
/>
<
telerik:GridBoundColumn
DataField
=
"COW_LifeId"
HeaderText
=
"Birth ID"
DataType
=
"System.String"
ReadOnly
=
"true"
HeaderStyle-Width
=
"8em"
/>
<
telerik:GridBoundColumn
DataField
=
"COW_VID"
HeaderText
=
"Current Visual ID"
DataType
=
"System.Int32"
ReadOnly
=
"true"
HeaderStyle-Width
=
"8em"
/>
<
telerik:GridTemplateColumn
DataField
=
"COW_VID"
HeaderText
=
"New Visual ID"
DataType
=
"System.Int32"
ReadOnly
=
"false"
HeaderStyle-Width
=
"15em"
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
runat
=
"server"
ID
=
"tbNewVisualID"
SelectionOnFocus
=
"SelectAll"
AutoPostBack
=
"false"
MinValue
=
"0"
MaxValue
=
"999999"
>
<
NumberFormat
DecimalDigits
=
"0"
GroupSeparator
=
""
/>
<
ClientEvents
OnKeyPress
=
"TelerikVisualIDKeyPress"
OnValueChanged
=
"TelerikValueChanged"
/>
</
telerik:RadNumericTextBox
>
<
span
class
=
"errorText"
style
=
"display: none"
>*NOT UNIQUE*</
span
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
</
div
>
public
partial
class
_Default : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
}
protected
void
RadGrid1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
var data =
new
List<
object
>();
for
(
int
i = 0; i < 1000; i++)
{
data.Add(
new
{Cow_Id = i, Cow_EID = i,cow_LifeId = i, Cow_VID = i});
}
TGrid.DataSource = data;
}
protected
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
foreach
(GridItem item
in
TGrid.MasterTableView.Items)
{
if
(item
is
GridEditableItem)
{
GridEditableItem editableItem = item
as
GridDataItem;
editableItem.Edit =
true
;
}
}
TGrid.Rebind();
}
}
Running the code shows the editable column correctly, however changing the page size doesn't work as expected. Paging however seems to work fine.
If I comment out TGrid.Rebind();, or
editableItem.Edit =
true
;
then changing the page size works as expected, but then the column is not editable. Any thoughts?Thanks in advance.