Hi,
(dataset beginner)
I want to be able to extract the values on the current inserted grid row, and insert them to a dataset using a custom function i wrote.
I started to define this insertCommand method:
which i found on your site, but the first line fails in type conversion from DataCommandItem.
I want to be able to get something like that:
but I'm not sure how to extract the current record that is inserted. can you please write here a simple code or just refer me to a relevant documentation?
Thanks in advance,
Hadar
(dataset beginner)
I want to be able to extract the values on the current inserted grid row, and insert them to a dataset using a custom function i wrote.
I started to define this insertCommand method:
protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
{ |
GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item; |
I want to be able to get something like that:
string LastName = (insertedItem["LastName"].Controls[0] as TextBox).Text; |
string FirstName = (insertedItem["FirstName"].Controls[0] as TextBox).Text; |
string Title = (insertedItem["Title"].Controls[0] as TextBox).Text; |
string Address = (insertedItem["Address"].Controls[0] as TextBox).Text; |
string City = (insertedItem["City"].Controls[0] as TextBox).Text; |
Thanks in advance,
Hadar
3 Answers, 1 is accepted
0
Hi Hadar,
The following article contains additional information on how to get the newly entered data.
I hope this gets you started properly.
Regards,
Yavor
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
The following article contains additional information on how to get the newly entered data.
I hope this gets you started properly.
Regards,
Yavor
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Cliff
Top achievements
Rank 1
answered on 30 Dec 2008, 12:23 AM
Hey Hadar,
I find the examples referenced terribly confusing, especially since I am also a beginner.
I am using the following example to get the values from the inserted row and pass them to a custom insert method
use the ExtractValues function to populate a hashtable, then access each value by key, or iterate the collection.
HTH,
Cliff
I find the examples referenced terribly confusing, especially since I am also a beginner.
I am using the following example to get the values from the inserted row and pass them to a custom insert method
use the ExtractValues function to populate a hashtable, then access each value by key, or iterate the collection.
Protected Sub RadGrid1_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) |
'expected insert values(Case Sensitive):Email, UserName, FirstName, LastName |
Dim values As New Hashtable |
Dim insertedItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem) |
insertedItem.ExtractValues(values) |
Dim email As String = values("Email") |
Dim username As String = values("UserName") |
... |
MyCustomInsertMethod(value1, value2, ...) |
HTH,
Cliff
0

Hk
Top achievements
Rank 2
answered on 30 Dec 2008, 07:33 AM
Thank you both. this is radgrid1:
I also want to add that I'm binding the data manually:
After fired, I put the following lines from the article you linked:
But editedItem returns null! why?
<telerik:RadGrid ID="RadGrid1" Skin="Vista" Width="97%" AllowSorting="True" AllowPaging="True" |
runat="server" ShowFooter="True" PageSize="7" AllowMultiRowEdit="True" |
AllowAutomaticInserts="false" AllowAutomaticUpdates="false" AllowAutomaticDeletes="false" |
OnInsertCommand="RadGrid1_InsertCommand" OnItemInserted="RadGrid1_ItemInserted" |
OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCommand="RadGrid1_ItemCommand" |
OnItemCreated="RadGrid1_ItemCreated" |
> |
<HeaderContextMenu Skin="Vista" EnableTheming="True"> |
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
</HeaderContextMenu> |
<PagerStyle Mode="NextPrevAndNumeric" /> |
<MasterTableView Width="100%" GridLines="None" CommandItemDisplay="Top" EditMode="InPlace" |
HorizontalAlign="NotSet" AutoGenerateColumns="False" DataKeyNames="iCaptureId"> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridBoundColumn DataField="iCaptureId" DataType="System.Int32" HeaderText="iCaptureId" |
ReadOnly="True" SortExpression="iCaptureId" UniqueName="iCaptureId"> |
</telerik:GridBoundColumn> |
<EditColumn UniqueName="EditCommandColumn1"> |
</EditColumn> |
</EditFormSettings> |
<CommandItemTemplate> |
<div style="padding: 0 5px;"> |
Custom command item template |
<asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected" Visible='<%# RadGrid1.EditIndexes.Count == 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="../../DataEditing/Img/Edit.gif" />Edit selected</asp:LinkButton> |
<asp:LinkButton ID="btnUpdateEdited" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="../../DataEditing/Img/Update.gif" />Update</asp:LinkButton> |
<asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" Visible='<%# RadGrid1.EditIndexes.Count > 0 || RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="../../DataEditing/Img/Cancel.gif" />Cancel editing</asp:LinkButton> |
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="InitInsert" Visible='<%# !RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="../../DataEditing/Img/AddRecord.gif" />Add new</asp:LinkButton> |
<asp:LinkButton ID="LinkButton3" runat="server" CommandName="PerformInsert" Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="../../DataEditing/Img/Insert.gif" /> Add this Customer</asp:LinkButton> |
<asp:LinkButton ID="LinkButton1" OnClientClick="javascript:return confirm('Delete all selected customers?')" |
runat="server" CommandName="DeleteSelected"><img style="border:0px;vertical-align:middle;" alt="" src="../../DataEditing/Img/Delete.gif" />Delete selected customers</asp:LinkButton> |
<asp:LinkButton ID="LinkButton4" runat="server" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="../../DataEditing/Img/Refresh.gif" />Refresh customer list</asp:LinkButton> |
</div> |
</CommandItemTemplate> |
</MasterTableView> |
<ClientSettings> |
<Selecting AllowRowSelect="True" EnableDragToSelectRows="True" /> |
</ClientSettings> |
<FilterMenu Skin="Vista" EnableTheming="True"> |
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
</FilterMenu> |
</telerik:RadGrid> |
I also want to add that I'm binding the data manually:
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) |
{ |
RadGrid1.DataSource = captureDS; |
//RadGrid1.DataBind(); |
} |
After fired, I put the following lines from the article you linked:
protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e) |
{ |
GridEditableItem eeditedItem = e.Item as GridEditableItem; |
GridEditManager editMan = editedItem.EditManager; |
. |
. |
. |
} |
But editedItem returns null! why?