
Jeff Montgomery
Top achievements
Rank 1
Jeff Montgomery
asked on 08 Oct 2009, 06:53 PM
We are evaluating the Telerik controls for web use, and I have a couple of questions that I don't see answered here:
1. Is it possible to set every row to edit mode in the .aspx markup (as opposed to using the Edit property in the code-behind)?
2. Does the built-in binding update only dirty rows (rows that have changed) or does it update *every* row that is posted back in edit mode?
Thanks for any help,
Jeff
1. Is it possible to set every row to edit mode in the .aspx markup (as opposed to using the Edit property in the code-behind)?
2. Does the built-in binding update only dirty rows (rows that have changed) or does it update *every* row that is posted back in edit mode?
Thanks for any help,
Jeff
10 Answers, 1 is accepted
0
Hello Jeff,
Currently the RadGrid does not provide a markup property for setting items into edit mode. However on the server you can use several options. Please review the following links for more details.
Default edit mode for grid items on initial load
Put all items in edit mode without additional rebind
When you have more than one item set into edit mode and perform a postback (other than hitting the update button of an item), no items will be updated and after the postback these items will still be into edit mode. To perform a batch update I would suggest you to try the solution provided in the following help topic:
Performing batch updates
I hope this helps.
Regards,
Martin
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Currently the RadGrid does not provide a markup property for setting items into edit mode. However on the server you can use several options. Please review the following links for more details.
Default edit mode for grid items on initial load
Put all items in edit mode without additional rebind
When you have more than one item set into edit mode and perform a postback (other than hitting the update button of an item), no items will be updated and after the postback these items will still be into edit mode. To perform a batch update I would suggest you to try the solution provided in the following help topic:
Performing batch updates
I hope this helps.
Regards,
Martin
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0

Jeff Montgomery
Top achievements
Rank 1
answered on 14 Oct 2009, 03:53 PM
Thank you for the input. We actually want all rows in edit mode all the time. My solution ended up as follows. We set all grid rows to edit mode on the server side:
Then update any dirty rows on PostBack:
protected void RadGrid1_PreRender(object sender, EventArgs e) |
{ |
foreach (GridDataItem row in RadGrid1.Items) |
{ |
row.Edit = true; |
} |
RadGrid1.Rebind(); |
} |
Then update any dirty rows on PostBack:
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
{ |
if (e.CommandName == "Apply") |
{ |
foreach (GridEditableItem editedItem in RadGrid1.EditItems) |
{ |
Hashtable newValues = new Hashtable(); |
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); |
if (isDirty(editedItem.SavedOldValues, newValues)) |
{ |
string sql = String.Format("UPDATE [Products] SET [ProductName] = '{0}', [CategoryID] = {1}, [QuantityPerUnit] = '{2}', [UnitPrice] = {3}, [UnitsInStock] = {4}, [Discontinued] = '{5}' WHERE [ProductID] = {6}", safeSql(newValues["ProductName"].ToString()), newValues["CategoryID"], newValues["QuantityPerUnit"], newValues["UnitPrice"], newValues["UnitsInStock"], newValues["Discontinued"], editedItem.GetDataKeyValue("ProductID").ToString()); |
SqlDataSource1.UpdateCommand = sql; |
SqlDataSource1.Update(); |
} |
} |
} |
RadGrid1.Rebind(); |
} |
private bool isDirty(IDictionary oldValues, Hashtable newValues) |
{ |
foreach (DictionaryEntry oldEntry in oldValues) |
{ |
object oldObjectValue = oldEntry.Value; |
string oldObjectKey = oldEntry.Key.ToString(); |
foreach (DictionaryEntry newEntry in newValues) |
{ |
object newObjectValue = newEntry.Value; |
string newObjectKey = newEntry.Key.ToString(); |
// If the items are the same, compare old and new. |
if (oldObjectKey == newObjectKey) |
{ |
if (!oldObjectValue.Equals(newObjectValue)) |
{ |
return true; |
} |
} |
} |
} |
return false; |
} |
0

Jessy Joseph
Top achievements
Rank 1
answered on 22 Sep 2010, 09:38 PM
Jeff,
Can you show how you did on Aspx page. I have two columns in the grid which I want to show in the editmode, one is texbox and other is dropdown but in my case when the grid is loaded it's not showing the editform.
Jessy
Can you show how you did on Aspx page. I have two columns in the grid which I want to show in the editmode, one is texbox and other is dropdown but in my case when the grid is loaded it's not showing the editform.
Jessy
0

Princy
Top achievements
Rank 2
answered on 23 Sep 2010, 06:32 AM
Hello Jessy,
Check whether you have set AllowMultiRowEdit property of RadGrid as 'True', which indicates whether Telerik RadGrid will allow you to have multiple rows in edit mode at a time.
Also the help artcle shows how to achieve this:
Default edit mode for grid items on initial load
Thanks,
Princy.
Check whether you have set AllowMultiRowEdit property of RadGrid as 'True', which indicates whether Telerik RadGrid will allow you to have multiple rows in edit mode at a time.
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowMultiRowEdit
=
"true"
>
Also the help artcle shows how to achieve this:
Default edit mode for grid items on initial load
Thanks,
Princy.
0

Jessy Joseph
Top achievements
Rank 1
answered on 23 Sep 2010, 03:06 PM
Princy,
I had already set AllowMultiRowEdit property of RadGrid as 'True', still it's not showing in the Editmode. My one column is a dropdown in the editmode so I have used GridTemplateColumn instead of GridBoundColumn
Thanks.
Jessy
I had already set AllowMultiRowEdit property of RadGrid as 'True', still it's not showing in the Editmode. My one column is a dropdown in the editmode so I have used GridTemplateColumn instead of GridBoundColumn
<
telerik:GridTemplateColumn
UniqueName
=
"ActionName"
HeaderText
=
"ActionName"
SortExpression
=
"ActionName"
HeaderStyle-Width
=
"15%"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblActionName"
runat
=
"server"
Text='<%# Eval("ActionName") %>' />
<
asp:DropDownList
ID
=
"ddlActionName"
runat
=
"server"
DataTextField
=
"ActionName"
DataValueField
=
"CampaignChecklistActionID"
DataSourceID
=
"dsAction"
Style
=
"display: none"
>
</
asp:DropDownList
>
</
ItemTemplate
>
<
HeaderStyle
Width
=
"15%"
></
HeaderStyle
>
</
telerik:GridTemplateColumn
>
Thanks.
Jessy
0

Princy
Top achievements
Rank 2
answered on 24 Sep 2010, 07:02 AM
Hello Jessy,
If you want to show the DropDownList in edit mode, you have to place it in EditItemTemplate of GridTemplateColumn.
ASPX:
Thanks,
Princy.
If you want to show the DropDownList in edit mode, you have to place it in EditItemTemplate of GridTemplateColumn.
ASPX:
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
asp:DropDownList
ID
=
"ddlActionName"
runat
=
"server"
DataTextField
=
"FirstName"
DataValueField
=
"FirstName"
DataSourceID
=
"SqlDataSource1"
>
</
asp:DropDownList
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
Thanks,
Princy.
0

Manish
Top achievements
Rank 1
answered on 07 Nov 2011, 04:10 AM
Why not to try GridDropDownColumn?
<
telerik:GridDropDownColumn
DataField
=
"psm_status"
DataSourceID
=
"SqlDataSource3"
HeaderText
=
"Status"
ListTextField
=
"psm_statusname"
ListValueField
=
"psm_status"
UniqueName
=
"Status"
ColumnEditorID
=
"GridDropDownColumnEditor1"
HeaderStyle-Width
=
"130px"
/>
0

mahima jain
Top achievements
Rank 1
answered on 21 Jan 2013, 10:57 AM
Hi all,
Is this is only way i mean the way which is mentioned jeff Montgomery .... i am facing the same problem ... and didn't get any solution ....... please let me know is this is only solution or telerik grid provide any inbuilt property which tell us how whether this row is changed or not ? i tried link mention by martin for batch update but its broken .....
Is this is only way i mean the way which is mentioned jeff Montgomery .... i am facing the same problem ... and didn't get any solution ....... please let me know is this is only solution or telerik grid provide any inbuilt property which tell us how whether this row is changed or not ? i tried link mention by martin for batch update but its broken .....
0

Shinu
Top achievements
Rank 2
answered on 21 Jan 2013, 11:52 AM
Hi,
You can access the new values in ItemCommand event as shown below.
C#:
Also check the following help documentation for more about batch updates.
Performing Batch Updates
Thanks,
Shinu
You can access the new values in ItemCommand event as shown below.
C#:
protected
void
RadGrid1_ItemCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.CommandName ==
"Update"
)
{
foreach
(GridEditableItem editedItem
in
RadGrid1.EditItems)
{
Hashtable newValues =
new
Hashtable();
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
string
id = newValues[
"Uniquename"
].ToString();
}
}
}
Performing Batch Updates
Thanks,
Shinu
0

Brijesh Gadhiya
Top achievements
Rank 1
answered on 04 Feb 2013, 10:39 PM
Thanks!
This is what I was looking for a small project i was working on where I want to persist the edited items into some List or DataTable rather have it bind a SqlDataSource or an ObjectDataSource and update from UI.
Brijesh
This is what I was looking for a small project i was working on where I want to persist the edited items into some List or DataTable rather have it bind a SqlDataSource or an ObjectDataSource and update from UI.
Brijesh