I am using the radGrid and am updating values using edit forms.
On the code behind I couldn't get the updated values that i entered in the text-boxes. It always shows the old values. I have tried two approaches. using the ExtractValuesFromItem(dictonaryObject, editedItem) method and Fetching the data from each edited field individually through the auto-generated column editors, which both seems not to work. here is the markup for the grid and the code behind.
I would appreciate if somebody can help me out with this issue. I only have a day.
<tlrk:RadGrid ID="tlrkExpGrid" runat="server" CellSpacing="0"
GridLines="None" AutoGenerateColumns = "False"
OnUpdateCommand = "expDG_RowUpdating" ><MasterTableView commanditemdisplay="Top" EditMode = "EditForms" DataKeyNames = "ex_code">
<Columns>
<tlrk:GridEditCommandColumn ButtonType="LinkButton" UniqueName="EditCommandColumn">
<ItemStyle CssClass="MyImageButton"/>
</tlrk:GridEditCommandColumn>
<tlrk:GridBoundColumn DataField="ex_code" HeaderText="Code" UniqueName="ex_code" >
</tlrk:GridBoundColumn>
<tlrk:GridBoundColumn DataField="ex_name" HeaderText="Name" UniqueName="ex_name" >
</tlrk:GridBoundColumn>
<tlrk:GridBoundColumn DataField="DUNS" HeaderText="DUNS" UniqueName="DUNS" >
</tlrk:GridBoundColumn>
<tlrk:GridBoundColumn DataField="email" HeaderText="Email" UniqueName="email" ColumnEditorID = "emailEditor">
</tlrk:GridBoundColumn>
<tlrk:GridButtonColumn ConfirmText="Delete this Exporter?" ConfirmDialogType="RadWindow"
ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
UniqueName="DeleteColumn">
<ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
</tlrk:GridButtonColumn></Columns>
<EditFormSettings>
<EditColumn UniqueName="EditCommandColumn" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>
</EditFormSettings>
</MasterTableView>
</tlrk:RadGrid>
protected
void expDG_RowUpdating(object source,Telerik.Web.UI.GridCommandEventArgs e)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
string expCode = (editedItem["ex_code"].Controls[0] as TextBox).Text;
string expName = (editedItem["ex_name"].Controls[0] as TextBox).Text;
string duns = (editedItem["DUNS"].Controls[0] as TextBox).Text;
string email = (editedItem["email"].Controls[0] as TextBox).Text;
//this is the first approach
Hashtable newValues = new Hashtable();
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
 
//this was the second approach trying to loop through each editor 
GridTextBoxColumnEditor editor = (GridTextBoxColumnEditor)editedItem.EditManager.GetColumnEditor("email");
TextBox t = editor.TextBoxControl;
string ee = t.Text;
GridEditableItem editedItem = e.Item as GridEditableItem;
GridEditManager editMan = editedItem.EditManager;
foreach( GridColumn column in e.Item.OwnerTableView.RenderColumns )
{
if ( column is IGridEditableColumn )
{
IGridEditableColumn editableCol = (column as IGridEditableColumn);
if ( editableCol.IsEditable )
{
IGridColumnEditor editor = editMan.GetColumnEditor( editableCol );
string editorType = editor.ToString();
string editorText = "unknown";
object editorValue = null;
if ( editor is GridTextColumnEditor )
{
editorText = (editor as GridTextColumnEditor).Text;
editorValue = (editor as GridTextColumnEditor).Text;
}
}
}
}