Hi
I'm trying to create one aspx page for each table in my database in order to update them.
My page has a Radgrid to select items to edit.
I'm using 3 DIVs, one with RadGrid, another with the buttons to edit an add new items and a third div with all controls needed to fill my database table.
When div Datagrid is visible, div controls is invisible. This is working ok with client code that I execute from the server using AjaxMaster
My controls will use asp.net validators when ok button is clicked.
All my database accesses are done through server code.
I done a lot of configurations with Ajax but there are always a problem.
All my buttons are related with server events, before I start with client code events that call server code through Ajaxrequest, but then I got problems with my asp.net validators that wont fired.
The situation I have now is like this:
============================
I put one AjaxPanel inside each DIV:
RadAjaxLoadingPanel3 has Button bt_edit, bt_new, label with selected radgrid item and some hidden fields that I need in server side
RadAjaxLoadingPanel2 has RadGrid
RadAjaxLoadingPanel1 has all the controls I need to fill and also my butons bt_ok and bt_cancelar to validade or cancel.
At this stage, Edit and Add buttons are working, my validators are working but I havesame problems to solve when I press ok button to validate my controls:
> when reading RadInput textboxes on server code, the text value I get is the old value before I make the changes. If I use a normal text box, this works ok. (Radtexbox example: <telerik:RadTextBox ID="tx_match_user" runat="server"></telerik:RadTextBox>)
> After saving data I need to refresh Radgrid and my code don't work. I'm using this code in another page and it wotks ok, but the call starts from a javascrip function, here it starts form server code
> when I select a grid item, i store the name in label that is inside RadAjaxLoadingPanel3. Every time I click bt_edit or bt_new that are inside the same Radajaxpanel, this label gets empty.
The main parts of my code:
======================
My last MasterAjax configuration:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="bt_edit">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="bt_new">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="Bt_ok">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="Bt_Cancelar">
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
My server code to execute javascript from server (I try both ways and they do what I need):
Private Sub execute_js(ByVal script As String)
ScriptManager.RegisterClientScriptBlock(Me, Page.GetType(), "PopupWindow", script, True)
'RadAjaxManager1.ResponseScripts.Add(script)
End Sub
My server code to refresh Radgrid that is called when I finish to update my database:
Private Sub grid2_refresh(ByVal tipo As Integer)
'obtem o tipo de operação efectuado
If tipo = 2 Then RadGrid1.CurrentPageIndex = 0
RadGrid1.DataSource = load_DBdata()
RadGrid1.Rebind()
End Sub
Protected Sub RadGrid1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.DataBound
rd.Close()
cn.Close()
End Sub
Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
RadGrid1.DataSource = load_DBdata()
End Sub
Private Function load_DBdata() As SqlDataReader
Try
cn = New SqlConnection
cn.ConnectionString = DB_STRING
cn.Open()
Dim command As SqlCommand = New SqlCommand("Sp_Users_List", cn)
With command
.CommandType = Data.CommandType.StoredProcedure
.Parameters.Add("@login_id", Data.SqlDbType.BigInt)
.Parameters("@login_id").Value = 0
End With
'
rd = command.ExecuteReader
Catch ex As Exception
Return rd
End Function
Best regards
I'm trying to create one aspx page for each table in my database in order to update them.
My page has a Radgrid to select items to edit.
I'm using 3 DIVs, one with RadGrid, another with the buttons to edit an add new items and a third div with all controls needed to fill my database table.
When div Datagrid is visible, div controls is invisible. This is working ok with client code that I execute from the server using AjaxMaster
My controls will use asp.net validators when ok button is clicked.
All my database accesses are done through server code.
I done a lot of configurations with Ajax but there are always a problem.
All my buttons are related with server events, before I start with client code events that call server code through Ajaxrequest, but then I got problems with my asp.net validators that wont fired.
The situation I have now is like this:
============================
I put one AjaxPanel inside each DIV:
RadAjaxLoadingPanel3 has Button bt_edit, bt_new, label with selected radgrid item and some hidden fields that I need in server side
RadAjaxLoadingPanel2 has RadGrid
RadAjaxLoadingPanel1 has all the controls I need to fill and also my butons bt_ok and bt_cancelar to validade or cancel.
At this stage, Edit and Add buttons are working, my validators are working but I havesame problems to solve when I press ok button to validate my controls:
> when reading RadInput textboxes on server code, the text value I get is the old value before I make the changes. If I use a normal text box, this works ok. (Radtexbox example: <telerik:RadTextBox ID="tx_match_user" runat="server"></telerik:RadTextBox>)
> After saving data I need to refresh Radgrid and my code don't work. I'm using this code in another page and it wotks ok, but the call starts from a javascrip function, here it starts form server code
> when I select a grid item, i store the name in label that is inside RadAjaxLoadingPanel3. Every time I click bt_edit or bt_new that are inside the same Radajaxpanel, this label gets empty.
The main parts of my code:
======================
My last MasterAjax configuration:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="bt_edit">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="bt_new">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="Bt_ok">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" />
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="Bt_Cancelar">
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
My server code to execute javascript from server (I try both ways and they do what I need):
Private Sub execute_js(ByVal script As String)
ScriptManager.RegisterClientScriptBlock(Me, Page.GetType(), "PopupWindow", script, True)
'RadAjaxManager1.ResponseScripts.Add(script)
End Sub
My server code to refresh Radgrid that is called when I finish to update my database:
Private Sub grid2_refresh(ByVal tipo As Integer)
'obtem o tipo de operação efectuado
If tipo = 2 Then RadGrid1.CurrentPageIndex = 0
RadGrid1.DataSource = load_DBdata()
RadGrid1.Rebind()
End Sub
Protected Sub RadGrid1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.DataBound
rd.Close()
cn.Close()
End Sub
Protected Sub RadGrid1_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
RadGrid1.DataSource = load_DBdata()
End Sub
Private Function load_DBdata() As SqlDataReader
Try
cn = New SqlConnection
cn.ConnectionString = DB_STRING
cn.Open()
Dim command As SqlCommand = New SqlCommand("Sp_Users_List", cn)
With command
.CommandType = Data.CommandType.StoredProcedure
.Parameters.Add("@login_id", Data.SqlDbType.BigInt)
.Parameters("@login_id").Value = 0
End With
'
rd = command.ExecuteReader
Catch ex As Exception
Return rd
End Function
Best regards