I am binding grid using Needdatasource event.It works fine in normal case.
I have filter textbox for one of my column and I am validating the filter values in the ItemCommand event.Data is being fetched for the given filter value and could see the data in the Radgrid.DataSource.But the grid shows no records to display.Why the grid is not bind with the fetched data?
Please find below my code.
aspx.cs
Please let me know if the above code has anu issues.without filter the grid binds properly.
Thanks,
Soumya
I have filter textbox for one of my column and I am validating the filter values in the ItemCommand event.Data is being fetched for the given filter value and could see the data in the Radgrid.DataSource.But the grid shows no records to display.Why the grid is not bind with the fetched data?
Please find below my code.
<telerik:RadGrid ID="gvPhoneInq" runat="server" CellSpacing="0" GridLines="None" AllowSorting="True" AllowFilteringByColumn="True" AllowPaging = "True" AutoGenerateColumns="False" OnNeedDataSource="gvPhoneInq_NeedDataSource" OnItemCommand="gvPhoneInq_ItemCommand" OnSelectedIndexChanged="gvPhoneInq_SelectedIndexChanged" > <PagerStyle Mode="NextPrevAndNumeric"/> <GroupingSettings CaseSensitive="false" /> <ClientSettings EnablePostBackOnRowClick="true"> <Selecting AllowRowSelect="true" /> </ClientSettings> <MasterTableView CommandItemDisplay="Top" NoMasterRecordsText="No Phone enquiry records exist!" CommandItemStyle-BackColor="lightblue" CommandItemStyle-Font-Bold="true" GridLines="None" DataKeyNames="Ph_EnqID" > <Columns> <telerik:GridBoundColumn HeaderText="Mobile No" UniqueName="Ph_PhNo" DataField="Ph_PhNo" > <FilterTemplate> <telerik:RadTextBox ID="RTMob" runat="server" Width="200px" ClientEvents-OnValueChanged="ValueChanged1" ></telerik:RadTextBox> <telerik:RadScriptBlock ID="RBMob" runat="server"> <script type="text/javascript"> function ValueChanged1(sender, args) { var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>"); var Name = $find('<%# ((GridItem)Container).FindControl("RTMob").ClientID %>'); tableView.filter("Ph_PhNo", Name, "EqualTo"); } </script> </telerik:RadScriptBlock> </FilterTemplate> </telerik:GridBoundColumn> </Columns><EditFormSettings > <EditColumn UniqueName="EditCo
mmandColumn1" ></EditColumn> </EditFormSettings> <CommandItemStyle BackColor="LightBlue" Font-Bold="True"></CommandItemStyle> </MasterTableView> </telerik:RadGrid>aspx.cs
protected void gvPhoneInq_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) { _phoneEnqServices = new PhoneEnqServices(); gvPhoneInq.DataSource = _phoneEnqServices.GetAllPatients(search); } protected void gvPhoneInq_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == RadGrid.FilterCommandName) { Pair filterPair = (Pair)e.CommandArgument; switch (filterPair.Second.ToString()) { case ("Ph_PhNo"): { flagD = 0; RadTextBox searchMob = (e.Item as GridFilteringItem)[filterPair.Second.ToString()].FindControl("RTMob") as RadTextBox; search = " where Ph_PhNo ='" + searchMob.Text + "'"; break; } } } }Please let me know if the above code has anu issues.without filter the grid binds properly.
Thanks,
Soumya