My Question is how can I update the data in the radgrid when the user clicks the Submit button/ Close button of radwindow.Please help..
Thanks in advance
3 Answers, 1 is accepted
Checkout the demo which demonstrates how to use RadWindow for editing RadGrid records. I hope this would helpful for you in achieving the functionality.
Window Editing
-Shinu.
Thank you for your efforts.
I go thru' the telerik sample application.In my case , everything works fine except the grid is refreshed/updated.But after adding the refreshGrid script & RadAjaManager, even the radwindow doesn't open.Hereby I include my code.please review and advise me.Thanks a lot.
default.aspx
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function
ShowWindow()
{
var oWnd = window.radopen('leadcontactedit.aspx', 'window1');
}
function
refreshGrid(arg)
{
if(!arg)
{
$find(
"<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");
}
else
{
$find(
"<%= RadAjaxManager1.ClientID %>").ajaxRequest("RebindAndNavigate");
}
}
</
script>
</
telerik:RadCodeBlock>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="RadGrid1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadGrid1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" GridLines="None">
<MasterTableView ClientDataKeyNames="sno" DataKeyNames="sno" DataSourceID="SqlDataSource1">
<Columns>
<telerik:GridButtonColumn CommandName="Select" Text="Edit" UniqueName="column1">
</telerik:GridButtonColumn>
<telerik:GridBoundColumn DataField="firstname" HeaderText="First Name" UniqueName="firstname">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="lastname" HeaderText="Last Name" UniqueName="lastname">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="worktitle" HeaderText="Work Title" UniqueName="worktitle">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="businessphone" HeaderText="Off. Phone" UniqueName="businessphone">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="cellphone" HeaderText="Mobile" UniqueName="cellphone">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="department" HeaderText="Dept" UniqueName="department">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="email" HeaderText="Email" UniqueName="email">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="sno" HeaderText="S.No" UniqueName="sno" Visible="False">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="True" />
</ClientSettings>
</telerik:RadGrid>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" ReloadOnShow="True" Modal="True">
<Windows>
<telerik:RadWindow ID="radwindow1" runat="server" ShowContentDuringLoad="False" NavigateUrl="detailsedit.aspx"></telerik:RadWindow>
</Windows>
</telerik:RadWindowManager>
default.aspx.vb
Protected Sub RadGrid1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.SelectedIndexChanged
Dim myVal As String
myVal = RadGrid1.SelectedItems(0).OwnerTableView.DataKeyValues(RadGrid1.SelectedItems(0).ItemIndex)(
"sno")
RadGrid1.Controls.Add(
New LiteralControl(" U clicked Contact No:" & myVal))
script = "<script language='javascript' type='text/javascript'>Sys.Application.add_load(ShowWindow);</script>"
ClientScript.RegisterStartupScript(Me.GetType(), "showWindow", script)
End Sub
Protected
Sub RadAjaxManager1_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs) Handles RadAjaxManager1.AjaxRequest
If e.Argument = "Rebind" Then
RadGrid1.MasterTableView.SortExpressions.Clear()
RadGrid1.MasterTableView.GroupByExpressions.Clear()
RadGrid1.Rebind()
ElseIf e.Argument = "RebindAndNavigate" Then
RadGrid1.MasterTableView.SortExpressions.Clear()
RadGrid1.MasterTableView.GroupByExpressions.Clear()
RadGrid1.MasterTableView.CurrentPageIndex = RadGrid1.MasterTableView.PageCount - 1
RadGrid1.Rebind()
End If
End Sub
below is the code I used for update query in the click of Submit button ( this code is in the detailsedit.aspx.vb)
Dim MyQuery As String
Dim Mycommand As SqlCommand
Dim MyContactSno As String = Session("MyLeadContactSno")
cn.Open()
MyQuery =
"update contactmaster set firstname='" & TxtFirstName.Text & "',lastname='" & TxtlastName.Text & "',worktitle='" & TxtWorkTitle.Text & "',department='" & TxtDepartment.Text & "',decisionrole='" & Txtdecision.Text & "',businessphone='" & TxtOffPhone.Text & "',homephone='" & TxtHomePhone.Text & "',cellphone='" & TxtMobile.Text & "',email='" & TxtEmail.Text & "',status='" & LstStatus.SelectedValue & "' where sno='" & MyContactSno & "'"
'&"',lastname='"& &"',worktitle='"& &"',department='"& &"'"
Mycommand =
New SqlCommand(MyQuery, cn)
Mycommand.ExecuteNonQuery()
Mycommand.Dispose()
Label12.Text =
"<script type='text/javascript'>Close()</" + "script>"
In the detailsedit.aspx
<
script language ="javascript" type ="text/javascript" >
function GetRadWindow()
{
var oWindow = null;
if (window.radWindow)
oWindow = window.RadWindow;
//Will work in Moz in all cases, including clasic dialog
else if (window.frameElement.radWindow)
oWindow = window.frameElement.radWindow;
//IE (and Moz as well)
return oWindow;
}
function Close()
{
GetRadWindow().Close();
}
</
script>
I have already answered your support ticket.
Sincerely yours,
Fiko
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.