Hi
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TestPartialPostback.aspx.vb"
Inherits="Rentware.TestPartialPostback" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
div
>
<
br
/>
<
telerik:RadFormDecorator
ID
=
"rfDecorator"
runat
=
"server"
DecoratedControls
=
"Buttons,Fieldset,RadioButtons,CheckBoxes"
/>
<
telerik:RadWindowManager
runat
=
"server"
ID
=
"radWindowMgr"
/>
<
telerik:RadAjaxManager
ID
=
"radAjaxMgr"
runat
=
"server"
>
<
ajaxsettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"cbTest"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"testPanel"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
ajaxsettings
>
</
telerik:RadAjaxManager
>
<
h2
>
Account Management</
h2
>
<
telerik:RadTabStrip
ID
=
"RadTabsAccManage"
runat
=
"server"
MultiPageID
=
"RadMultiPageAccManage"
SelectedIndex
=
"0"
Skin
=
"WebBlue"
>
<
tabs
>
<
telerik:RadTab
Text
=
"General"
>
</
telerik:RadTab
>
<
telerik:RadTab
Text
=
"Contacts"
>
</
telerik:RadTab
>
</
tabs
>
</
telerik:RadTabStrip
>
<
telerik:RadMultiPage
ID
=
"RadMultiPageAccManage"
runat
=
"server"
SelectedIndex
=
"0"
>
<
telerik:RadPageView
ID
=
"RadPageViewAccManageGeneral"
runat
=
"server"
>
<
telerik:RadGrid
ID
=
"RadGridAccManageMain"
runat
=
"server"
GridLines
=
"None"
AutoGenerateColumns
=
"False"
ShowStatusBar
=
"true"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
DataSourceID
=
"SqlDataSource1"
>
<
alternatingitemstyle
cssclass
=
"DisplayNone"
/>
<
itemstyle
cssclass
=
"DisplayNone"
/>
<
headerstyle
cssclass
=
"DisplayNone"
/>
<
footerstyle
cssclass
=
"DisplayNone"
/>
<
groupingsettings
casesensitive
=
"false"
/>
<
mastertableview
gridlines
=
"None"
datasourceid
=
"SqlDataSource1"
autogeneratecolumns
=
"false"
datakeynames
=
"RegionID"
>
<
Columns
>
<
telerik:GridTemplateColumn
ItemStyle-HorizontalAlign
=
"Center"
AllowFiltering
=
"false"
>
<
ItemTemplate
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTemplate
>
<
asp:CheckBox
ID
=
"cbTest"
runat
=
"server"
Text
=
"Enable"
TextAlign
=
"Left"
OnCheckedChanged
=
"checkBoxCheckedChanaged"
AutoPostBack
=
"true"
/>
<
asp:Panel
ID
=
"testPanel"
runat
=
"server"
Enabled
=
"false"
>
<
fieldset
>
<
legend
>Add Or Edit Region:</
legend
>Region Description:
<
asp:TextBox
runat
=
"server"
ID
=
"txtText"
Text='<%#Bind("RegionDescription") %>' />
</
fieldset
></
asp:Panel
>
</
FormTemplate
>
</
EditFormSettings
>
</
mastertableview
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT [RegionID], [RegionDescription] FROM [Region] WHERE ([RegionID] = @RegionID)"
runat="server">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"RegionID"
SessionField
=
"regionId"
Type
=
"Int32"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
</
telerik:RadPageView
>
<
telerik:RadPageView
ID
=
"RadPageViewAccManageContacts"
runat
=
"server"
>
</
telerik:RadPageView
>
</
telerik:RadMultiPage
>
</
div
>
</
form
>
</
body
>
</
html
>
Imports Telerik.Web.UI
Partial Public Class TestPartialPostback
Inherits System.Web.UI.Page
Dim regionId As Integer
Dim commandName As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
regionId = Convert.ToInt32(Convert.ToString(Request.QueryString("regionId")))
Session("regionId") = regionId
End If
commandName = IIf(Session("regionId").Equals(0), "PerformInsert", "Update").ToString()
End Sub
Private Sub RadGridAccManageMain_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGridAccManageMain.ItemCreated
If TypeOf e.Item Is GridEditableItem AndAlso commandName = "Update" Then
e.Item.Edit = True
End If
End Sub
Protected Sub RadGridAccManageMain_PreRender(ByVal sender As Object, ByVal e As EventArgs) Handles RadGridAccManageMain.PreRender
If Not Page.IsPostBack And commandName = "PerformInsert" Then
RadGridAccManageMain.MasterTableView.IsItemInserted = True
RadGridAccManageMain.Rebind()
'RadGridAccManageMain.MasterTableView.InsertItem()
RadGridAccManageMain.HeaderStyle.CssClass = "rgEditRow"
End If
End Sub
Protected Sub checkBoxCheckedChanaged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim thisCheckBox As CheckBox = CType(sender, CheckBox)
Dim editItem As GridEditFormItem = DirectCast(thisCheckBox.NamingContainer, GridEditFormItem)
CType(editItem.FindControl("testPanel"), Panel).Enabled = thisCheckBox.Checked
End Sub
End Class
I’m using RadGrid for editing and inserting row in the place of using asp.net form view. I’m passing the parameter to select the row for editing through query string.I’m assigning that query string to session variable in page load event and that session variable serves as select parameter in SQL Data source.If I get the required query string I’m putting RadGrid in Item Edit Mode and if not It will open the RadGrid in Item Insert mode.Inside Form Template I’ve a checkbox and asp.net panel that wraps all other contents of Form Template. I have an event to handle check box checked status changed.In that event I’m enabling and disabling the panel based on if the checkbox is checked or not.
I’ve RadAjaxManager in place with Ajax settings. I’ve an AJAX setting in that RadAjaxManager with AjaxControlID as ID of the checkbox and AJAX updated control ID as the ID of the panel. So If I check or uncheck the checkbox In either Edit Mode or Insert Mode the panel should be enabled or disabled through AJAX partial post back.
Problem/Bug:
If the page loaded in insert mode for the first time and if I check the checkbox it is doing full post back and I can observe that clearly. (This is not expected behaviour).If I check the checkbox again it is doing partial ajaxified post back.But In Edit mode it is working fine (doing partial ajaxified post back) at all time.How I can fix this issue. For your reference I’ve attached the aspx and code behind file for you. It is stopping us from progressing further; your help would be very much appreciated.