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

Can't Get Out of Edit Mode

6 Answers 188 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 18 Sep 2008, 07:48 PM
Hi..
I'm using the grid with the 'built in' editing.

When I call the Insert_Command my record is added.
But the grid still displays in edit mode.
I've tried  e.item.edit = false in the code below but the insert does not work.

If I try

//condition for Insert Mode

if ((e.Item is GridEditFormInsertItem) && (e.Item.OwnerTableView.IsItemInserted))

{

GridEditFormInsertItem insertitem = (GridEditFormInsertItem)e.Item;

//this.RadGridPhone.MasterTableView.ClearEditItems();

e.Item.Edit = false;

}


 The insert gets turned 'off' before inserting...

I've als tried 

this.RadGridPhone.MasterTableView.ClearEditItems()

But that does noting...


Any ideas ?? thanks

/// INSERT COMMAND

protected void RadGridPhone_InsertCommand(object source, GridCommandEventArgs e)

{

try

{

GridEditFormItem gridEditFormItem = (GridEditFormItem)e.Item;

Hashtable ht = new Hashtable();

gridEditFormItem.ExtractValues(ht);

//Create new row in the DataSource

DataRow newRow = this.Phone.NewRow();

newRow[

"PHONEEMAILORURL"] = ht["PhoneEmailOrURL"].ToString();

newRow[

"CONSTPHONEOREMAILTYPEID"] = ht["ConstPhoneorEmailTypeID"].ToString();

this.Phone.Rows.Add(newRow);

this.Phone.AcceptChanges();

this.RadGridPhone.DataSource = this.Phone;

this.RadGridPhone.DataBind();

}

catch (Exception ex)

{

this.RadGridPhone.Controls.Add(new LiteralControl("Unable to update/insert Phone Record. Reason: " + ex.Message));

e.Canceled =

true;

}

}



6 Answers, 1 is accepted

Sort by
0
Guss
Top achievements
Rank 2
answered on 18 Sep 2008, 07:58 PM
I have the same problem with the insertcommand, updatecommand...but deletecommand does work.

I use the xml sample to the dot.

protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
{
GridEditFormItem gridEditFormItem = (GridEditFormItem)e.Item;
Hashtable ht = new Hashtable();
gridEditFormItem.ExtractValues(ht);
String Id = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString();
XmlNode node = XmlDataSource1.GetXmlDocument().SelectSingleNode(String.Format(str1, Id));
node.Attributes[
"Text"].Value = ConvertNullToEmpty(ht["Text"]);
node.Attributes[
"Value"].Value = ConvertNullToEmpty(ht["Value"]);
try { XmlDataSource1.Save(); }
catch (Exception ex) { lblMsg.Text = ex.Message; }
RefreshXmlFile();
}

The only difference is that it is used in that I use masterpages so the grid is within ContentPlaceHolder and I've rapped it in a RadAjaxPanel.

Everything else is working fine. It does update, delete and insert, it is just that it stays in edit mode. The only way getting out of the edit mode is clicking on the CANCEL button afterwards.

Regards
Guss
0
Jon
Top achievements
Rank 1
answered on 18 Sep 2008, 08:09 PM
Exact problem !
Thanks for your response..
I'm not alone...!!!!!!!!!!!!

Any ideas???????????????????

0
Guss
Top achievements
Rank 2
answered on 18 Sep 2008, 08:18 PM
I've waisted a whole 3 hours on that :-(
I've tried all the stuff you did...

..now I suspecting the RadAjaxPanel and / or the fact that I use a masterpage.
In my case it is one non important pages where I use this technique...so I have moved on.

(The technique I usaully use which works fine is to bind to my sqldatasource and use inert update delete and select stored procedure. - I've only ran into this problem for a few pages where I use xml data and had to go with this custom command technique)

Sorry, I have no more ideas...but I will also watch what telerik support has to say.

Regards
0
Jon
Top achievements
Rank 1
answered on 18 Sep 2008, 08:49 PM
thanks..
I wonder if  datasource and binding,  fire some event that effect the edit.........................
0
Bruno
Top achievements
Rank 2
answered on 18 Sep 2008, 09:23 PM
Guys,

I suppose this subject was widely discussed already...

RadGrid Row still in Edit Mode After Update
In-Line Edit Mode in RadGrid, Remain in Edit and Insert Mode
RadGrid In-line Edit mode.
Cancel edit mode for all grid rows
Edit Form Doesn't Close When I clcik the Update Link button Returning from InPlace-Edit

(rhetorical question: guess if there are more of these...?)

It is always good to know that it's actually faster to find out the problem by yourself (using regular SEARCH) instead of waiting for someone else to solve your simple questions.
0
Jon
Top achievements
Rank 1
answered on 18 Sep 2008, 09:39 PM
Thanks!

I saw some of these threads...

But missed the one with the solution...

"Did you set AllowAutomaticUpdates and AllowAutomaticInserts to true? If that is the case, please set them to false. These properties are used only with datasource controls as shown here."

Tags
Grid
Asked by
Jon
Top achievements
Rank 1
Answers by
Guss
Top achievements
Rank 2
Jon
Top achievements
Rank 1
Bruno
Top achievements
Rank 2
Share this question
or