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

RadGrid cell text reset on row selection.

1 Answer 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ramez
Top achievements
Rank 1
Ramez asked on 14 Feb 2012, 06:26 PM
I have a radgrid and one of the columns is a GridButtonColumn with a ButtonType="PushButton" with the default text set to "Add". On the ItemDataBound routine I update the text value with the number of items that were added. So when the grid rebinds it now displays the number of added items. Works fine up to now.

Here is where it gets messed up. If I select a row in the grid, all the values in the column reset back to "Add". It seems that the re-rendering of the grid resets all the column values back to the defaults. If the grid is re-bound the values are back again. So it's not a data issue, it's a rendering issue on row selection.

I completely removed any code in the OnSelectedIndexChanged event, so it's nothing to do with any code in that event. It has something to do with the AllowRowSelect directive with EnablePostBackOnRowClick="true". The ItemDataBound routine is not called on row selection, is there another event I can re-set my values to? Would I have to write a routine that loops through each row and sets the proper values after the selection has been made?

I would think the the databindings should persist after a row selection.

<telerik:RadGrid ID="rg_ExportDetail" runat="server" ShowStatusBar="true" OnItemDataBound="rg_ExportDetail_ItemDataBound" OnSelectedIndexChanged="rg_ExportDetail_SelectedIndexChanged"

 

OnNeedDataSource="rg_ExportDetail_NeedDataSource" OnItemCommand="rg_ExportDetail_ItemCommand" Skin="Vista"

 

<MasterTableView TableLayout="Auto" EditMode="InPlace" AutoGenerateColumns="false" ClientDataKeyNames="ExportItemID">

 

<NoRecordsTemplate>

<div>There are no records to display</div>

</NoRecordsTemplate>

<Columns>

<telerik:GridBoundColumn DataField="ExportItemID" UniqueName="ExportItemID" Visible="false" />

<telerik:GridBoundColumn DataField="ExportDate" UniqueName="ExportDate" Visible="true" HeaderText="ExportDate" />

<telerik:GridBoundColumn DataField="Description" UniqueName="Description" Visible="true" HeaderText="Description" HeaderStyle-Width="300px" />

<telerik:GridBoundColumn DataField="ECL" UniqueName="ECL" Visible="false" HeaderText="ECL#" />

<telerik:GridBoundColumn DataField="Quantity" UniqueName="Quantity" Visible="false" HeaderText="Quantity" />

<telerik:GridBoundColumn DataField="UnitValue" UniqueName="UnitValue" Visible="false" HeaderText="Unit Value" DataType="System.Double" DataFormatString="{0:C}"/>

<telerik:GridBoundColumn DataField="TotalValue" UniqueName="TotalValue" Visible="true" HeaderText="Total Value" />

<telerik:GridButtonColumn ButtonType="PushButton" UniqueName="Consignees" text="Add" HeaderText="Consignee(s)" CommandName="AddConsignees" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="120px" />

<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" ItemStyle-HorizontalAlign="Center" ConfirmText="Removing Item"></telerik:GridButtonColumn>

</Columns>

<ItemStyle HorizontalAlign="Left" CssClass="disabledFontColorEmphasis" Wrap="false" />

<AlternatingItemStyle HorizontalAlign="Left" CssClass="disabledFontColorEmphasis"

Wrap="false" />

<HeaderStyle HorizontalAlign="Left" Wrap="false" Width="100px" />

<FilterItemStyle HorizontalAlign="Left" />

</MasterTableView>

<ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true" >

<Selecting AllowRowSelect="True" />

</ClientSettings>

</telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 17 Feb 2012, 07:52 AM
Hi Ramez,

Just use the ItemCreated event instead to set the text of the column.
 
Regards,
Tsvetoslav
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
Grid
Asked by
Ramez
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or