
johnson lim
Top achievements
Rank 1
johnson lim
asked on 03 Oct 2011, 02:26 PM
Hi,
My RadGrid not able to get back to display mode after user inser data.
This is the scenario
1). Have the command Name to InitInsert so that RadGrid enter insert data mode.
2).When user click button add ,it call command PerformInsert which in turn fire event RadGrid.InsertCommand.
3).User input is inserted to database and RadGrid.Rebind() is called in order to refresh added data.
4).However the RadGrid is not able to go back to display mode. There is 1 more addtional row there for user to key in their input.
Help Please!!
My RadGrid not able to get back to display mode after user inser data.
This is the scenario
1). Have the command Name to InitInsert so that RadGrid enter insert data mode.
2).When user click button add ,it call command PerformInsert which in turn fire event RadGrid.InsertCommand.
3).User input is inserted to database and RadGrid.Rebind() is called in order to refresh added data.
4).However the RadGrid is not able to go back to display mode. There is 1 more addtional row there for user to key in their input.
Help Please!!
4 Answers, 1 is accepted
0

Jayesh Goyani
Top achievements
Rank 2
answered on 03 Oct 2011, 03:07 PM
Hello,
Please provide your code.
Thanks,
Jayesh Goyani
Please provide your code.
Thanks,
Jayesh Goyani
0

johnson lim
Top achievements
Rank 1
answered on 03 Oct 2011, 03:59 PM
Hi
Jayesh Goyani, here is my code.. HELP Please !!
VB Code
Protected Sub ajaxVendorDetail_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles ajaxVendorDetail.InsertCommand
Try
Dim strEmailId As String
Dim strCompanyNo As String
Dim strVendorId As String
strCompanyNo = ajaxVendor.SelectedItems(0).OwnerTableView.DataKeyValues(ajaxVendor.SelectedItems(0).ItemIndex)("CompNo")
strVendorId = ajaxVendor.SelectedItems(0).OwnerTableView.DataKeyValues(ajaxVendor.SelectedItems(0).ItemIndex)("VendorId")
strEmailId = Trim(CType(e.Item.FindControl("txtEmailID"), RadTextBox).Text)
InsertVendorDetail(strCompanyNo, strVendorId, strEmailId)
ajaxVendorDetail.Rebind()
Catch ex As Exception
Dim Msg As String = ""
Msg = ex.Message.ToString.Replace("'", "")
RadAjaxManager1.ResponseScripts.Add("alert('" + Msg + "');")
End Try
End Sub
Code Behind
<
ajax:RadGrid
ID
=
"ajaxVendorDetail"
runat
=
"server"
DataSourceID
=
"sqlVendorDetail"
AutoGenerateColumns
=
"false"
AllowAutomaticUpdates
=
"true"
AllowAutomaticDeletes
=
"true"
AllowAutomaticInserts
=
"true"
AllowPaging
=
"true"
PageSize
=
"2"
>
<
SortingSettings
SortToolTip="<%$ Resources:Resource, Sort %>" />
<
ClientSettings
EnableRowHoverStyle
=
"True"
EnablePostBackOnRowClick
=
"false"
>
<
Selecting
AllowRowSelect
=
"false"
/>
</
ClientSettings
>
<
MasterTableView
EditMode
=
"InPlace"
DataKeyNames
=
"CompNo,VendorID,EmailID"
CommandItemDisplay
=
"Top"
AllowSorting
=
"True"
NoMasterRecordsText="<%$ Resources:Resource, Search_Display %>">
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
PagerTextFormat
=
"{2}{3}{4}Page {0} of {1}"
PageSizeLabelText
=
""
AlwaysVisible
=
"true"
NextPageToolTip="<%$ Resources:Resource, NextPage %>" PrevPageToolTip="<%$ Resources:Resource, PreviousPage %>" LastPageToolTip="<%$ Resources:Resource, LastPage %>" FirstPageToolTip="<%$ Resources:Resource, FirstPage %>"/>
<
CommandItemTemplate
>
<
table
style
=
"width: 100%"
cellpadding
=
"0"
cellspacing
=
"0"
>
<
tr
>
<
td
>
<
asp:Label
ID
=
"LblCommandTitle"
runat
=
"server"
CssClass
=
"gridTitle"
Text="<%$ Resources:Resource,EMailAddr %>" />
</
td
>
<
td
align
=
"right"
>
<
asp:LinkButton
ID
=
"BtnAdd"
runat
=
"server"
CommandName
=
"InitInsert"
Visible='<%# Not (ajaxVendorDetail.EditIndexes.Count > 0 OrElse ajaxVendorDetail.MasterTableView.IsItemInserted OrElse ajaxVendor.SelectedIndexes.Count = 0) %>'>
<
img
style
=
"border:0px"
alt
=
""
src
=
"images/icons/AddRecord.gif"
title='<%= Resources.Resource.Add_Record %>' />
</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"BtnRefresh"
runat
=
"server"
CommandName
=
"RebindGrid"
>
<
img
style
=
"border:0px"
alt
=
""
src
=
"images/icons/Refresh.gif"
title='<%= Resources.Resource.Refresh_Table%>'/>
</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"ExportToCsvButton"
runat
=
"server"
CommandName
=
"ExportToExcel"
Visible='<%# ajaxVendorDetail.Items.Count > 0 AndAlso Not(ajaxVendorDetail.EditIndexes.Count > 0 OrElse ajaxVendorDetail.MasterTableView.IsItemInserted) %>' >
<
img
style
=
"border:0px"
alt
=
""
src
=
"images/icons/application_go.gif"
title='<%= Resources.Resource.Export_Excel%>'/>
</
asp:LinkButton
>
</
td
>
</
tr
>
</
table
>
</
CommandItemTemplate
>
<
Columns
>
<
ajax:GridTemplateColumn
UniqueName
=
"GCUpdate"
HeaderStyle-Width
=
"20px"
>
<
ItemTemplate
>
<
asp:LinkButton
Style
=
"vertical-align: bottom"
ID
=
"btnEditSelected"
runat
=
"server"
CommandName
=
"Edit"
Visible='<%# Not (ajaxVendorDetail.EditIndexes.Count > 0 OrElse ajaxVendorDetail.MasterTableView.IsItemInserted) %>'>
<
img
style
=
"border:0px"
alt
=
""
src
=
"images/icons/Edit.gif"
title='<%= Resources.Resource.Edit %>' />
</
asp:LinkButton
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:LinkButton
ID
=
"BtnInsert"
runat
=
"server"
CommandName
=
"PerformInsert"
Visible='<%# ajaxVendorDetail.MasterTableView.IsItemInserted %>'>
<
img
style
=
"border:0px"
alt
=
""
src
=
"images/icons/disk.png"
title='<%= Resources.Resource.Insert %>' />
</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"BtnUpdate"
runat
=
"server"
CommandName
=
"UpdateEdited"
OnClientClick
=
"javascript:return confirmSaveMessage();"
Visible='<%# ajaxVendorDetail.EditIndexes.Count > 0 %>'>
<
img
style
=
"border:0px"
alt
=
""
src
=
"images/icons/disk.png"
title='<%= Resources.Resource.Update %>' />
</
asp:LinkButton
>
</
EditItemTemplate
>
</
ajax:GridTemplateColumn
>
<
ajax:GridTemplateColumn
UniqueName
=
"GCDelete"
HeaderStyle-Width
=
"20px"
>
<
ItemTemplate
>
<
asp:LinkButton
ID
=
"BtnDelete"
runat
=
"server"
CommandName
=
"Delete"
OnClientClick
=
"javascript:return confirmDeleteMessage();"
Visible='<%# Not (ajaxVendorDetail.EditIndexes.Count > 0 OrElse ajaxVendorDetail.MasterTableView.IsItemInserted) %>'>
<
img
style
=
"border:0px"
alt
=
""
src
=
"images/icons/Delete.gif"
title='<%= Resources.Resource.Delete %>' />
</
asp:LinkButton
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:LinkButton
ID
=
"BtnCancel"
runat
=
"server"
CommandName
=
"Cancel"
CausesValidation
=
"false"
>
<
img
style
=
"border:0px"
alt
=
""
src
=
"images/icons/Cancel.gif"
title='<%= Resources.Resource.btnCancel %>' />
</
asp:LinkButton
>
</
EditItemTemplate
>
</
ajax:GridTemplateColumn
>
<
ajax:GridTemplateColumn
UniqueName
=
"EmailID"
HeaderText
=
"EmailID"
SortExpression
=
"EmailID"
HeaderStyle-Width
=
"600px"
ItemStyle-VerticalAlign
=
"Top"
>
<
ItemTemplate
>
<%# DataBinder.Eval(Container.DataItem, "EmailID")%>
</
ItemTemplate
>
<
EditItemTemplate
>
<
ajax:RadTextBox
ID
=
"txtEmailID"
runat
=
"server"
Width
=
"550px"
Text='<%#Bind("EmailID") %>' MaxLength="500" ></
ajax:RadTextBox
>
<
br
/><
asp:RequiredFieldValidator
ID
=
"RFVtxtEmailID"
runat
=
"server"
ControlToValidate
=
"txtEmailID"
ErrorMessage="<%$ Resources:Resource, EmptyErrorMsg %>" Display="Dynamic" SetFocusOnError="true"></
asp:RequiredFieldValidator
>
<
asp:RegularExpressionValidator
runat
=
"server"
id
=
"RFVtxtEmailFormat"
SetFocusOnError
=
"true"
ControlToValidate
=
"txtEmailID"
ErrorMessage="<%$ Resources:Resource, VerifyEmailFormat %>"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" />
</
EditItemTemplate
>
</
ajax:GridTemplateColumn
>
<
ajax:GridTemplateColumn
UniqueName
=
"LMUser"
HeaderText="<%$ Resources:Resource, LMUser %>" SortExpression="LMUser" HeaderStyle-Width="140px" ItemStyle-VerticalAlign="Top">
<
ItemTemplate
>
<%# DataBinder.Eval(Container.DataItem, "LMUser")%>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:Label
ID
=
"LblLMUser"
runat
=
"server"
CssClass
=
"codelabel"
Text='<%# DataBinder.Eval(Container.DataItem, "LMUser")%>' Visible="true"></
asp:Label
>
</
EditItemTemplate
>
</
ajax:GridTemplateColumn
>
<
ajax:GridTemplateColumn
UniqueName
=
"LMDatetime"
HeaderText="<%$ Resources:Resource, LMDateTime %>" SortExpression="LMDatetime" HeaderStyle-Width="140px" ItemStyle-VerticalAlign="Top">
<
ItemTemplate
>
<%# FlexWebCommonModule.TimeZoneConverter.ConvertToLocalTimeString(DateTime.Parse(Eval("LMDatetime").ToString()))%>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:Label
ID
=
"lblEditLastModifiedOn"
runat
=
"server"
Text='<%# LMDateConvertor(Eval("LMDatetime").ToString) %>' Visible="true"></
asp:Label
>
</
EditItemTemplate
>
</
ajax:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
ajax:RadGrid
>
0
Accepted

Jayesh Goyani
Top achievements
Rank 2
answered on 03 Oct 2011, 06:22 PM
Hello,
please try with code snippet.
Thanks,
Jayesh Goyani
please try with code snippet.
AllowAutomaticInserts
=
"false"
Thanks,
Jayesh Goyani
0

johnson lim
Top achievements
Rank 1
answered on 04 Oct 2011, 02:25 AM
Hi Jayesh Goyani, it works .. muacks ^^