Hello
I have a RadGrid that works well : it shows the rows in the dataSource and I can use the seeded buttons to add rows etc ...
Now I want to some rows programmatically, so I modify the DataSource in the codeBehind then run RadGrid. Rebind() but it does not shows the new datasource rows.
What could be the explanation for this ?
Loko
I have a RadGrid that works well : it shows the rows in the dataSource and I can use the seeded buttons to add rows etc ...
Now I want to some rows programmatically, so I modify the DataSource in the codeBehind then run RadGrid. Rebind() but it does not shows the new datasource rows.
What could be the explanation for this ?
Loko
9 Answers, 1 is accepted
0
SANJAY
Top achievements
Rank 1
answered on 08 Aug 2014, 01:49 AM
Hi Arnaud
This works fine at my end
Protected Sub RadGrid1_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
Try
Dim r As New Data.DataSet
If IsNothing(Me.Session("ptls")) Then
'Code to Pouplate the recordset
Me.Session("ptls") = r
Else
r = CType(Me.Session("ptls"), Data.DataSet)
End If
RadGrid1.DataSource = r
Catch ex As Exception
End Try
End Sub
Protected Sub btnadd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnadd.Click
Try
Dim r As New Data.DataSet
r = CType(Me.Session("ptls"), Data.DataSet)
'Code to Add the records in the data.dataset
Me.Session("ptls") = r
RadGrid1.Rebind()
Catch ex As Exception
End Try
End Sub
After the Ragrid1.Rebind() is called the _NeedDataSource function is called. It reads the dataset from session and gets the updated dataset which is used to populate the grid
Hope this solves your query
Regards
Sanjay
This works fine at my end
Protected Sub RadGrid1_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles RadGrid1.NeedDataSource
Try
Dim r As New Data.DataSet
If IsNothing(Me.Session("ptls")) Then
'Code to Pouplate the recordset
Me.Session("ptls") = r
Else
r = CType(Me.Session("ptls"), Data.DataSet)
End If
RadGrid1.DataSource = r
Catch ex As Exception
End Try
End Sub
Protected Sub btnadd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnadd.Click
Try
Dim r As New Data.DataSet
r = CType(Me.Session("ptls"), Data.DataSet)
'Code to Add the records in the data.dataset
Me.Session("ptls") = r
RadGrid1.Rebind()
Catch ex As Exception
End Try
End Sub
After the Ragrid1.Rebind() is called the _NeedDataSource function is called. It reads the dataset from session and gets the updated dataset which is used to populate the grid
Hope this solves your query
Regards
Sanjay
0
SANJAY
Top achievements
Rank 1
answered on 08 Aug 2014, 01:55 AM
Hi Arnaud
Just in case you are using the Ajax to update the page kindly include the RadGrid in the Updatedcontrol list.
Regards
Sanjay
Just in case you are using the Ajax to update the page kindly include the RadGrid in the Updatedcontrol list.
Regards
Sanjay
0
Arnaud
Top achievements
Rank 1
answered on 11 Aug 2014, 09:24 AM
Hi
Sorry for the delay to answer.
In my case too , the Rebind() makes Radgrid run the NeedDataSource code, the DataSource now contains the new rows but I can't see them on screen, looks like the Radgrid display is not refreshed or something like that.
Please find my files here :
http://wikisend.com/download/305932/PopupMarketing.aspx
http://wikisend.com/download/819472/PopupMarketing.aspx.cs
- grid is "RadGrid_Regroupements"
- "RadButton_ArticleReference_Valid_Click" is run when you click on the first button, it grabs some data from DB then sets them in the TSession variable I use to keep data, then it runs sub-proc "SetModeleRegroupement" to do the Rebind().
Regards
Arnaud
Sorry for the delay to answer.
In my case too , the Rebind() makes Radgrid run the NeedDataSource code, the DataSource now contains the new rows but I can't see them on screen, looks like the Radgrid display is not refreshed or something like that.
Please find my files here :
http://wikisend.com/download/305932/PopupMarketing.aspx
http://wikisend.com/download/819472/PopupMarketing.aspx.cs
- grid is "RadGrid_Regroupements"
- "RadButton_ArticleReference_Valid_Click" is run when you click on the first button, it grabs some data from DB then sets them in the TSession variable I use to keep data, then it runs sub-proc "SetModeleRegroupement" to do the Rebind().
Regards
Arnaud
0
SANJAY
Top achievements
Rank 1
answered on 12 Aug 2014, 03:41 AM
Hi Arnaud
Your code seems to be correct.
Please check on
1) When the Needsource is called again if the TSuppression has all the new rows as well ( I am sure that you would have checked the same, just a gentle reminder)
2) I guess you are sure that new column data has same name as in original as the grid is bound to.
3) Set the id desc if you which to see the new rows on the top
Just in case I have not been able to give you a solution, I feel sorry for the same
Regards
Your code seems to be correct.
Please check on
1) When the Needsource is called again if the TSuppression has all the new rows as well ( I am sure that you would have checked the same, just a gentle reminder)
2) I guess you are sure that new column data has same name as in original as the grid is bound to.
3) Set the id desc if you which to see the new rows on the top
Just in case I have not been able to give you a solution, I feel sorry for the same
Regards
0
SANJAY
Top achievements
Rank 1
answered on 12 Aug 2014, 05:27 AM
Hi Arnaud
A word of caution
the original recordset
id, Value
5, A
4,B
3, c
2,d
1, e
Now you add 1 record so the recordset is
5, A
4,B
3, c
2,d
1, e
6, f
the new record comes at the end of the recordset and not at the begining
This is because the sorting of the session object doesnot occur by itself
We donot search of the record at the end of the file and miss it
If this is the problem then we could explicitly sort the record set and then bind to Grid
Regards
A word of caution
the original recordset
id, Value
5, A
4,B
3, c
2,d
1, e
Now you add 1 record so the recordset is
5, A
4,B
3, c
2,d
1, e
6, f
the new record comes at the end of the recordset and not at the begining
This is because the sorting of the session object doesnot occur by itself
We donot search of the record at the end of the file and miss it
If this is the problem then we could explicitly sort the record set and then bind to Grid
Regards
0
Arnaud
Top achievements
Rank 1
answered on 12 Aug 2014, 08:23 AM
Hi Sanjay
Thanks for the reminders. I really appreciate your time and tips.
Finally I found out the issue : I had to remove the RadAjaxManager in my asp page and it works.
Arnaud
Thanks for the reminders. I really appreciate your time and tips.
Finally I found out the issue : I had to remove the RadAjaxManager in my asp page and it works.
Arnaud
0
SANJAY
Top achievements
Rank 1
answered on 12 Aug 2014, 10:25 AM
Hi
Radajaxmanager comes in way if
1) If you donot enumeratd Radgrid in list of Upldated Controls
2) It also come in way if you asp:panel
Thanks for the feed back
Regards
Sanjay
Radajaxmanager comes in way if
1) If you donot enumeratd Radgrid in list of Upldated Controls
2) It also come in way if you asp:panel
Thanks for the feed back
Regards
Sanjay
0
Hi Arnaud,
I have inspected the provided code and noticed that both RadAjaxManager and RadAjaxPanel are used to Ajax-enable the same controls. This must not be done as when the controls are Ajax-ified multiple times they may not work as expected.
As you have seen for yourself when only one of the Ajax-enabling controls is used, the functionality works as expected.
Regards,
Viktor Tachev
Telerik
I have inspected the provided code and noticed that both RadAjaxManager and RadAjaxPanel are used to Ajax-enable the same controls. This must not be done as when the controls are Ajax-ified multiple times they may not work as expected.
As you have seen for yourself when only one of the Ajax-enabling controls is used, the functionality works as expected.
Regards,
Viktor Tachev
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Arnaud
Top achievements
Rank 1
answered on 13 Aug 2014, 07:10 AM
Thanks you Sanjay and Viktor for your explanations.
Regards
Arnaud
Regards
Arnaud