This is a migrated thread and some comments may be shown as answers.

radgrid.needdatasource is not working while calling radgrid.rebind

16 Answers 328 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Priya
Top achievements
Rank 1
Priya asked on 26 Aug 2008, 04:46 AM
Sir
I called radgrid.rebind() in linkbutton click.But the needdatasource event of that grid is not firing.Any help..
The aspx code is

<telerik:RadDock runat="server" ID="rddockPrjTypes" Title="Project Types">
<
ContentTemplate>
<telerik:RadGrid runat="server" ID="grdProjectTypes" Skin="Vista" AutoGenerateColumns="False"CssClass="gridnew" GridLines="None" ShowHeader="false">
<
ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">

 <Selecting AllowRowSelect="True" />
</
ClientSettings>
<
MasterTableView NoDetailRecordsText="" NoMasterRecordsText="">
<
Columns>
<
telerik:GridTemplateColumn UniqueName="TemplateColumn">                                <ItemTemplate>

<asp:LinkButton ID="lnkPTypes" runat="server" Text='<%#DataBinder.Eval(Container,"DataItem.projecttypedesc") %>'></asp:LinkButton> (<asp:LinkButton ID="lnkCount" runat="server" Text='<%#DataBinder.Eval(Container,"DataItem.counts") %>'></asp:LinkButton>                                                             ) </ItemTemplate>
</
telerik:GridTemplateColumn>

  </Columns>
<
EditFormSettings>
<
PopUpSettings ScrollBars="None"></PopUpSettings>                            </EditFormSettings><ExpandCollapseColumn Visible="False" Resizable="False"><HeaderStyle Width="20px"></HeaderStyle></ExpandCollapseColumn>            </MasterTableView></telerik:RadGrid> </ContentTemplate></telerik:RadDock>

thanks

16 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 26 Aug 2008, 05:12 AM
Hi Priya,

I guess you are setting the NeedDataSource event handler in the code behind. Sending your code behind will be more good.

Thanks
Shinu.
0
Priya
Top achievements
Rank 1
answered on 26 Aug 2008, 05:18 AM

Protected Sub grdProjectTypes_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdProjectTypes.NeedDataSource

Try

Dim ds As New DataSet()

ds = GetProjectTypes(

"PType")

If ds.Tables(0).Rows.Count > 1 Then

grdProjectTypes.DataSource = ds

End If

Catch ex As Exception

Dim er As ErrHandler = New ErrHandler(ex)

er.RaiseError()

End Try

End Sub

0
Priya
Top achievements
Rank 1
answered on 26 Aug 2008, 05:52 AM
any idea...plz help me..its urgent
0
Priya
Top achievements
Rank 1
answered on 26 Aug 2008, 06:01 AM
I hav three grids grdProjectTypes,grdPriority,grdStatus

Protected

Sub lnkRemoveFilter_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkRemoveFilter.Click

grdProjectTypes.Rebind()

grdPriority.Rebind()

grdStatus.Rebind()

End Sub


and when clicking on the linkbutton sometimes only grdProjectTypes needdatasource  is working.Sometimes only grdPriority needdatasource event  is working .wht wib the prbm.I actually much confused by this prblm
Plz help me....
0
Shinu
Top achievements
Rank 2
answered on 26 Aug 2008, 06:28 AM
Hi Priya,

Could you please paste the portion of the code in which you are adding the NeedDataSource Event handler ?

Shinu
0
Priya
Top achievements
Rank 1
answered on 26 Aug 2008, 06:44 AM
Thanks alot..

i m using .net2005.
Did u mean 

Protected Sub grdProjectTypes_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdProjectTypes.NeedDataSource

Try

Dim ds As New DataSet()

ds = GetProjectTypes(

"PType")

If ds.Tables(0).Rows.Count > 1 Then

grdProjectTypes.DataSource = ds

End If

Catch ex As Exception

Dim er As ErrHandler = New ErrHandler(ex)

er.RaiseError()

End Try

End Sub

0
Shinu
Top achievements
Rank 2
answered on 26 Aug 2008, 06:51 AM
Hi Priya,

Sorry for the confusion. I asked if you have set something like this in the code behind:

RadGrid1.NeedDataSource += new GridNeedDataSourceEventHandler(this.RadGrid1_NeedDataSource); 

The event will not be raised if you have not set the proper event handler.

Shinu
0
Priya
Top achievements
Rank 1
answered on 26 Aug 2008, 07:10 AM
I am using asp.net(VB) 2005.I cant see tht event handlers definition.I didnt add that handler manualy
thanks
0
Princy
Top achievements
Rank 2
answered on 26 Aug 2008, 07:26 AM
Hi Priya,

Try adding the NeedDataSource event handler either in the code behind or set it in the aspx page.

//Code behind
VB:
AddHandler RadGrid1.NeedDataSource, AddressOf Me.RadGrid1_NeedDataSource 
 

or

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource"
 


Regards
Princy
0
Priya
Top achievements
Rank 1
answered on 26 Aug 2008, 08:26 AM
Thanks..
i added another grid.Its rebind is working properly.It doesnot have the event handler.All grids have the same aspx codes.The only difference is Errorful grids are within RadDock.
0
Priya
Top achievements
Rank 1
answered on 26 Aug 2008, 08:39 AM

After adding the event handler the needdatasource is executing twice.But when i call rebind,needdatasource is not executing.
I tried by seting the enableviewstate to true and false.But no change.Rebind is stil not executing
0
Priya
Top achievements
Rank 1
answered on 26 Aug 2008, 08:56 AM
any help plz ...
0
Priya
Top achievements
Rank 1
answered on 26 Aug 2008, 09:59 AM
plz help me.....
0
Scott
Top achievements
Rank 1
answered on 05 Sep 2008, 07:08 PM
have you received any solution to this?  My NeedDataSource event handler is also firing twice.

Thanks
0
Priya
Top achievements
Rank 1
answered on 08 Sep 2008, 05:04 AM
no.I didnt get solution.I just removed tht eventhandler from aspx page
ie,
onneeddatasource="grid1_needdatasource" .i removed it.Now its working only once.
But my prbm is grid1.rebind() is not workg.I didnt get any solution

Thanks Scott
0
Sharmin
Top achievements
Rank 1
answered on 08 Aug 2013, 08:24 PM
I do not know whether you already got the answer. If not, try setting the radgrid's datasource to null and then rebind.

RadGrid1.DataSource = null
RadGrid1.Rebind();


Thanks,
Sharmin
Tags
Grid
Asked by
Priya
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Priya
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Scott
Top achievements
Rank 1
Sharmin
Top achievements
Rank 1
Share this question
or