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

agian can not call Grid ItemInserted

4 Answers 112 Views
Grid
This is a migrated thread and some comments may be shown as answers.
khalil_ck2002
Top achievements
Rank 1
khalil_ck2002 asked on 14 Mar 2011, 11:57 AM
Hello Dears

I post this subject agian please any help i will be grateful:)

I took the the Demo Gird Example with Delete ,Update ,Insert Buttons  but when i'm press any button the server side code didnt called .

 

 

<telerik:RadGrid ID="RadGrid1" runat="server" CssClass="RadGrid" GridLines="None"

 

 

 

AllowPaging="True" PageSize="20" AllowSorting="True" AutoGenerateColumns="False"

 

 

 

ShowStatusBar="True" AllowAutomaticDeletes="True" AllowAutomaticInserts="True"

 

 

 

AllowAutomaticUpdates="True" OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted"

 

 

 

OnItemUpdated="RadGrid1_ItemUpdated" OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender">

 

 

 

<MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="الأجراء">

 

 

 

<CommandItemSettings ExportToPdfText="Export to Pdf" />

 

 

 

<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">

 

 

 

</RowIndicatorColumn>

 

 

 

<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">

 

 

 

</ExpandCollapseColumn>

 

 

 

<Columns>

 

 

 

<telerik:GridEditCommandColumn CancelText="الغاء" EditText="تعديل" InsertText="حفظ"

 

 

 

UpdateText="تعديل">

 

 

 

</telerik:GridEditCommandColumn>

 

 

 

<telerik:GridBoundColumn UniqueName="Case Id" HeaderText="رقم الحالة" DataField="الحالة">

 

 

 

<HeaderStyle ForeColor="Silver" Width="20px"></HeaderStyle>

 

 

 

<ItemStyle ForeColor="Gray" />

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn UniqueName="Activity UID" HeaderText="رقم الأجراء" DataField="الأجراء">

 

 

 

<HeaderStyle ForeColor="Silver" Width="20px"></HeaderStyle>

 

 

 

<ItemStyle ForeColor="Gray" />

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn UniqueName="Type" HeaderText="نوع الأجراء" DataField="نوع">

 

 

 

<HeaderStyle Width="60px"></HeaderStyle>

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn UniqueName="Created" HeaderText="تاريخ الأجراء" DataField="تاريخ"

 

 

 

DataFormatString="{0:d}">

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn UniqueName="Owned By" HeaderText="الموظفين" DataField="الموظفين">

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridBoundColumn UniqueName="Description" HeaderText="الوصف" DataField="الوصف">

 

 

 

</telerik:GridBoundColumn>

 

 

 

<telerik:GridButtonColumn CommandName="Delete" Text="حذف" UniqueName="column">

 

 

 

</telerik:GridButtonColumn>

 

 

 

</Columns>

 

 

 

<EditFormSettings EditFormType="Template">

 

 

 

<EditColumn FilterControlAltText="Filter EditCommandColumn1 column" UniqueName="EditCommandColumn1">

 

 

 

</EditColumn>

 

 

 

<FormTemplate>

 

 

 

<table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"

 

 

 

style="border-collapse: collapse; background: white;">

 

 

 

<tr class="EditFormHeader">

 

 

 

<td colspan="2" style="font-size: small">

 

 

 

<b></b>

 

 

 

</td>

 

 

 

</tr>

 

 

 

<tr>

 

 

 

<td colspan="2">

 

 

 

<b></b>

 

 

 

</td>

 

 

 

</tr>

 

 

 

<tr>

 

 

 

<td>

 

 

 

<table id="Table3" cellspacing="1" cellpadding="1" width="250" border="0" class="module">

 

 

 

<tr>

 

 

 

<td>

 

 

 

</td>

 

 

 

<td>

 

 

 

</td>

 

 

 

</tr>

 

 

 

<tr>

 

 

 

<td>

 

رقم الأجراء:

 

 

</td>

 

 

 

<td>

 

 

 

<asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("الأجراء") %>'>

 

 

 

</asp:TextBox>

 

 

 

</td>

 

 

 

</tr>

 

 

 

<tr>

 

 

 

<td>

 

الموظفين:

 

 

</td>

 

 

 

<td>

 

 

 

<asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("الموظفين") %>' TabIndex="1">

 

 

 

</asp:TextBox>

 

<%

 

-- onclick="ShowPersonsDialog('الموظفين','Nationality','X_NATIONALITY','ctl00_ContentPlaceHolder1_RadGrid1_ctl00_ctl11_TextBox8');return false;"--%>

 

 

 

 

<button id="btnGrid" runat="server" style="width: 20px;">

 

...

 

 

</button>

 

 

 

</td>

 

 

 

</tr>

 

 

 

<tr>

 

 

 

<td>

 

 

 

</td>

 

 

 

<td>

 

 

 

</td>

 

 

 

</tr>

 

 

 

<tr>

 

 

 

<td>

 

تاريخ الأجراء:

 

 

</td>

 

 

 

<td>

 

 

 

<telerik:RadDatePicker ID="BirthDatePicker" runat="server" MinDate="1/1/1900" DbSelectedDate='<%# Eval("تاريخ") %>'

 

 

 

TabIndex="4">

 

 

 

</telerik:RadDatePicker>

 

 

 

</td>

 

 

 

</tr>

 

 

 

<tr>

 

 

 

<td>

 

نوع الأجراء

 

 

</td>

 

 

 

<td>

 

 

 

<asp:DropDownList ID="ddlTOC" runat="server" TabIndex="7" AppendDataBoundItems="True">

 

 

 

<asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>

 

 

 

</asp:DropDownList>

 

 

 

</td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</td>

 

 

 

<td>

 

 

 

<table id="Table1" cellspacing="1" cellpadding="1" width="250" border="0" class="module">

 

 

 

<tr>

 

 

 

<td>

 

الوصف:

 

 

</td>

 

 

 

</tr>

 

 

 

<tr>

 

 

 

<td>

 

 

 

<asp:TextBox ID="txtDesc" Text='<%# Bind("الوصف") %>' runat="server" TextMode="MultiLine"

 

 

 

Rows="5" Columns="40" TabIndex="5">

 

 

 

</asp:TextBox>

 

 

 

</td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</td>

 

 

 

</tr>

 

 

 

<tr>

 

 

 

<td align="right" colspan="2">

 

 

 

<asp:Button ID="btnUpdate" Text='<%# Iif (TypeOf Container is GridEditFormInsertItem, "Insert", "Update")%>'

 

 

 

runat="server" CommandName='<%#Iif (TypeOf Container is GridEditFormInsertItem, "PerformInsert", "Update") %>'>

 

 

 

</asp:Button>&nbsp;

 

<%

 

-- <asp:Button ID="btnUpdate" Text= "Insert"

 

 

runat="server" CommandName="PerformInsert" >

 

</asp:Button>&nbsp;

 

<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"

 

CommandName="Cancel"></asp:Button>--

 

 

%>

 

 

 

 

</td>

 

 

 

</tr>

 

 

 

</table>

 

 

 

</FormTemplate>

 

 

 

</EditFormSettings>

 

 

 

</MasterTableView>

 

 

 

<ClientSettings>

 

 

 

<ClientEvents OnRowDblClick="RowDblClick" />

 

 

 

</ClientSettings>

 

 

 

<FilterMenu EnableImageSprites="False">

 

 

 

</FilterMenu>

 

 

 

<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">

 

 

 

</HeaderContextMenu>

 

 

 

</telerik:RadGrid>

 

 

 

<telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor2" runat="server" TextBoxStyle-Width="150px" />

 



 

 

Protected Sub RadGrid1_ItemInserted(ByVal source As Object, ByVal e As GridInsertedEventArgs) Handles RadGrid1.ItemInserted

 

 

 

 

If e.Exception IsNot Nothing Then

 

e.ExceptionHandled =

 

True

 

e.KeepInInsertMode =

 

True

 

DisplayMessage(

 

True, "Employee cannot be inserted. Reason: " & Convert.ToString(e.Exception.Message))

 

 

 

 

Else

 

DisplayMessage(

 

False, "Employee inserted")

 

 

 

 

End If

 

 

 

Dim gridEditFormItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)

 

 

 

 

Dim dropDownList As DropDownList = DirectCast(gridEditFormItem.FindControl("ddlTOC"), DropDownList)

 

 

 

 

Dim TextBox As TextBox = DirectCast(gridEditFormItem.FindControl("TextBox8"), TextBox)

 

 

 

 

Dim txtDesc As TextBox = DirectCast(gridEditFormItem.FindControl("txtDesc"), TextBox)

 

 

 

 

Dim Btn As HtmlButton = DirectCast(gridEditFormItem.FindControl("btnGrid"), HtmlButton)

 

 

 

 

Dim strPartyInfo(,) As String

 

strPartyInfo = {{

 

"Type", dropDownList.SelectedItem.Text}, {"Owned By", TextBox.Text}, _

 

 

{

 

"Description", txtDesc.Text}, {"Case Id", rbDDLCorrCategory.SelectedItem.Text}}

 

 

setSiebelBusinessComponentData(

 

"HMM Correspondence", "Action", strPartyInfo)

 

 

 

 

End Sub

 


thank you

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Mar 2011, 12:10 PM
Hello,

The automatic data source operations only work when binding the grid to a Declarative DataSource using the DataSourceID property of the grid. For more information on this please go through the following documentation.
Automatic DataSource operations

-Shinu.
0
khalil_ck2002
Top achievements
Rank 1
answered on 15 Mar 2011, 11:33 AM
dear Shinu,

thank you for your help ..so waht should i do i have the following buttons :

<asp:Button ID="btnUpdate" Text='<%# Iif (TypeOf Container is GridEditFormInsertItem, "Insert", "Update")%>'

   

runat="server" CommandName='<%#Iif (TypeOf Container is GridEditFormInsertItem, "PerformInsert", "Update") %>'>

and i have the Item Command on Item Command event how can i access to the controls and take the values form it to save them in my database

thank you for you help

0
Shinu
Top achievements
Rank 2
answered on 15 Mar 2011, 11:54 AM
Hello Khalil,

You can try implementing the approach from the following help article for achieving your scenario.
Retrieving original values for edited item

Thanks,
Shinu.
0
khalil_ck2002
Top achievements
Rank 1
answered on 15 Mar 2011, 12:54 PM
dear Shinu,
its already depend on datasorce to and i dont any datasource i have data table
and i apply the article you sent but i got this reasonal error:
: Unable to cast object of type 'Telerik.Web.UI.GridCommandItem' to type 'Telerik.Web.UI.GridEditableItem'.

can i apply this example on my grid .

please tcan you take alook to my previous grid


Tags
Grid
Asked by
khalil_ck2002
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
khalil_ck2002
Top achievements
Rank 1
Share this question
or