This is a migrated thread and some comments may be shown as answers.
Rad Grid Rebind Problem
18 Answers 612 Views
This is a migrated thread and some comments may be shown as answers.
Denny
Top achievements
Rank 1
Denny asked on 28 Jun 2009, 08:18 AM
Hello,

In my site i am using Rad Grid,Rad Contex menu and  Rad popup features.
 
i am facing some problems :-
 1.    while i am inserting some through the Rad Popup , i am not being able to  rebining it.so newly inserted data are not showing in
        the Rad grid.Rad grid and Rad popup are  2 diiferent  Aspx page.
 2.    After inserting data through Rad popup  i want to close it automatically,How can i do this?


Thanks.
Denny

18 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 29 Jun 2009, 08:17 AM
Hi Denny,

On clicking the update/insert button in the window, you can register a client script as shown below:
c#
protected void Button1_Click(object sender, EventArgs e) 
        { 
             //Perform Insert  
             ClientScript.RegisterStartupScript(Page.GetType(), "mykey""CloseAndRebind();"true); 
      
        } 

You can then call a refreshGrid function defined in the Browser window  so as to pass window parameters , as shown below:
js:
function CloseAndRebind(args)  
        {  
            GetRadWindow().Close();  
            GetRadWindow().BrowserWindow.refreshGrid(args);  
        }  

In the refreshGrid function defined in the main page, you should in turn fire an ajax request:
js:
function refreshGrid(arg) 
           { 
             if(!arg) 
             { 
             $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("Rebind");             
             } 
           }

Rebind the grid after clearing the sort and group expressions in the AjaxRequest server side event:
c#:
 protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
        { 
            if (e.Argument == "Rebind"
            { 
                RadGrid1.MasterTableView.SortExpressions.Clear(); 
                RadGrid1.MasterTableView.GroupByExpressions.Clear(); 
                RadGrid1.Rebind(); 
            }            
        } 

Hope this helps..
Princy.
0
Denny
Top achievements
Rank 1
answered on 29 Jun 2009, 08:14 PM
Hello Princy,

I tried With your code,Its Doesn't works.

So i would like to request you please provide code me in zip format.Again i would like to inform you that  popup and main page are 2 different aspx page.

Plese provide me the code in this way so i can understood what i have to do.Otherwise what is mentioned in this article .I followed all these thing but doesn't works.

i am using the following Rad grid code for the page.So i am requesting you  to provide some
definite  solution considerding the following code.Here you can see i am using one aspx page  to show data in the grid.Another for popup .i want some specifice solution(in respect
exact to code with the aspx page and .Cs page).so i can solve the problem.We need to launch the site very soon.So please take this matter as urgent.I want the exact coding not any reference,because i already spent some days with your reference links/code  to solve this issue.

I am using Asp.net 2008 with C#.



please try to provide me specific solution.
---------------------------------

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="frmExplorer.aspx.cs" Inherits="WebInterface.frmExplorer" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Financial Portal</title>
    <link href="style/main.css" rel="stylesheet" type="text/css" />
    <link href="style/tabs.css" rel="stylesheet" type="text/css" />
    <link href="DocumentExplorer.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
     

    var gridViewCtlId = 'RadGrid1';
    var gridViewCtl = null;
    var curSelRow = null;
    var curRowIdx = -1;  
function OnClientItemClicked(sender, eventArgs)  
{  
    
     if (eventArgs.get_item().get_value() == "Move")  
    {  
        radopen("ContextMenuWindow.aspx?index="+index+"&value="+value , "window1");  
    }
     if (eventArgs.get_item().get_value() == "Rename")  
    {  
        radopen("RenameFolder.aspx?index="+index+"&value="+value , "window1");  
    }
     if (eventArgs.get_item().get_value() == "Delete")  
    {  
        radopen("ContextMenuWindow.aspx?index="+index+"&value="+value , "window1");  
    }
      if (eventArgs.get_item().get_value() == "Version")  
    {  
        radopen("ContextMenuWindow.aspx?index="+index+"&value="+value , "window1");  
    }
     if (eventArgs.get_item().get_value() == "Properties")  
    {  
        radopen("ContextMenuWindow.aspx?index="+index+"&value="+value , "window1");  
    }

   
var index = 0;  
var value;  
function OnRowContextMenu(sender, eventArgs)  
{  
    var menu = $find('RadMenu1');  
    var evt = eventArgs.get_domEvent();      
    if(evt.target.tagName == "INPUT" || evt.target.tagName == "A")  
    {  
      return;  
    }  
    index = eventArgs.get_itemIndexHierarchical();      
    var DataItem = $find('RadGrid1').get_masterTableView().get_dataItems()[index];  
    value = DataItem.getDataKeyValue("FolderId");
    var all=menu.get_allItems();
   

 
  
//        var serverID = "lblName";
//  var tagName = "select1"; //dropdowns render as <select> elements
//  
//  //var dropDown = GetRegisteredServerElement(serverID);
//  var dropDown = GetGridServerElement(serverID, tagName);
  
   
   
   
////    var grid = document.getElementById('RadGrid1'); 
////    var elements = grid.getElementsByTagName("jjj"); 
////   
////   
////    var currentCheckBox = sender.srcElement || sender.target;
////  
////    var inputs = document.getElementsByTagName("input");
////    for (var i = 0; i < inputs.length; i++)
////  {
////   var input = inputs[i];
////   if (input.id == currentCheckBox.id)
////   {
////     alert(currentCheckBox.id);
////    continue;
////    }
////  }

  
//    for(var i=0;i<all.length;i++)
//    {
//       all[i].hide();
//     
//    }
    //alert(DataItem);
   
   
   
   
    menu.show(evt);      
    evt.cancelBubble = true;  
    evt.returnValue = false;  
    if (evt.stopPropagation)  
    {  
       evt.stopPropagation();  
       evt.preventDefault();  
    }  
}  

 

 

  

</script> 
</head>
<body>
    <form id="form1" runat="server">
    <table width="100%">
   <tr>
   <td align="left" >
  <table width="100%" class="master_headertop">
  <tr>
  <td align="left" valign="middle" class="text4">Client Portal </td>
  <td  class="text5">&nbsp;</td>
  <td class="text5" align="right"><a href="#">Sign Out</a></td>
  </tr>
  </table>
    </td>
   </tr>
   <tr>
   <td align="left" >
   <telerik:RadScriptManager ID="ScriptManager1" runat="server" />
     <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
    
   <input type="hidden" id="radGridClickedRowIndex" name="radGridClickedRowIndex" />
       
            <p><asp:LinkButton ID="lnk_assignuser" class="backcolru" runat="server" Text="Upload Folder" OnClick="lnk_addLink_User" />
                <asp:LinkButton ID="LinkButton1" class="backcolru" runat="server"
                    Text="Upload File" onclick="LinkButton1_Click"  /></p>
            <p>
                  <telerik:radwindowmanager runat="server" Visible="false" RestrictionZoneID="offsetElement"  ID="RadWindowManager2">
               <Windows>
              
               <telerik:RadWindow ID="test1"              
               NavigateUrl = "UploadFolder.aspx"
               VisibleOnPageLoad = "true"
                VisibleStatusbar="false" Height="190" Width="365" Top = "100"
               Left = "200"
               runat="server"></telerik:RadWindow>
              
               </Windows>
               </telerik:radwindowmanager>
               <telerik:radwindowmanager runat="server" Visible="false" RestrictionZoneID="offsetElement" ID="RadWindowManager3">
               <Windows>
              
               <telerik:RadWindow ID="RadWindow1"              
               NavigateUrl = "uploadfile.aspx"
               VisibleOnPageLoad = "true"
                VisibleStatusbar="false" Height="190" Width="365" Top = "100"
               Left = "200"
               runat="server"></telerik:RadWindow>
              
               </Windows>
               </telerik:radwindowmanager>
              
     </p>
   <telerik:RadAjaxManager ID="RadAjaxManager1"  runat="server"> </telerik:RadAjaxManager>
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false"
            AllowPaging="false" GridLines="None" PageSize="20" Skin="Vista"
            AllowFilteringByColumn="false" Width="100%"
            onitemdatabound="grdDocument_ItemDataBound"
            onitemcommand="grdDocument_ItemCommand"> 
    <MasterTableView  PageSize="10"  TableLayout="Fixed"  
        ClientDataKeyNames="FolderId" AutoGenerateColumns="false">  
        
         <Columns>
            <telerik:GridTemplateColumn HeaderText="Type" Visible=false>
           
            <ItemTemplate>
               
            <asp:Label runat="server" ID="lblRecType" Text=<%# Eval("RecType") %> ></asp:Label>
            
           
            </ItemTemplate>
          
            </telerik:GridTemplateColumn>
           
          
            <telerik:GridTemplateColumn  HeaderText="Name">
           
            <ItemTemplate>
            <asp:ImageButton ID="imgType" runat="server" Visible="true" ImageUrl="~/Images/Ope_Folder.jpg" CommandName="RecType" value=<%# Eval("folderId") %> />
            <asp:Label runat="server" ID="lblName" Text=<%# Eval("docname") %> ></asp:Label>
             <asp:Label runat="server" ID="lblfolderid" Visible="false" Text=<%# Eval("folderId") %> ></asp:Label>
           
            </ItemTemplate>
           
            </telerik:GridTemplateColumn>
           
           
            <telerik:GridBoundColumn DataField="description" HeaderText="Description">
            </telerik:GridBoundColumn>
           
            <telerik:GridTemplateColumn HeaderText="Size">
           
            <ItemTemplate>
            <asp:Label runat="server" ID="lblFileSize" Text=<%# Eval("filesize") %> ></asp:Label>
           

            </ItemTemplate>
           
            </telerik:GridTemplateColumn>
                     
            
            <telerik:GridBoundColumn DataField="date" HeaderText="Received">
            </telerik:GridBoundColumn>

             <telerik:GridTemplateColumn HeaderText="FileType" Visible=false>
           
            <ItemTemplate>
            <asp:Label runat="server" ID="lblFileType" Text=<%# Eval("fileType") %> ></asp:Label>
           
            </ItemTemplate>
           
            </telerik:GridTemplateColumn> 
        </Columns>  
    </MasterTableView>  
    <ClientSettings>          
        <ClientEvents OnRowContextMenu="OnRowContextMenu" />  
    </ClientSettings>     
</telerik:RadGrid>  
 
<telerik:RadContextMenu ID="RadMenu1" runat="server"
        OnClientItemClicked="OnClientItemClicked">  
    <Items>  
              
                <telerik:RadMenuItem Text="Move"  Value="Move" />
                <telerik:RadMenuItem Text="Rename"  Value="Rename" />
                <telerik:RadMenuItem Text="Delete"  Value="Delete" />
                <telerik:RadMenuItem Text="Version History"  Value="Version" />
                <telerik:RadMenuItem Text="Properties"  Value="Properties" /> 
    </Items>  
</telerik:RadContextMenu>  
  
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"  Top = "100"
               Left = "50">  
</telerik:RadWindowManager>
   </td>
   </tr>
   
    </form>





Denny
0
C
Top achievements
Rank 1
answered on 16 Jul 2010, 02:46 PM
Hello Princy,

I have the same problem as stated by Denny. I did everything you have listed but the grid does not refresh. The call is made to the server side and the rebind() method is called but the browser does not refresh the grid.
Can you help me?

Sincerely,

CNB

PS: I am using Telerik.Web.UI.dll version 2010.1.519.35
0
Chandran Chandran
Top achievements
Rank 1
answered on 03 Sep 2010, 11:57 AM
Hi,
I am having the same issue, I just want to refresh the parent grid to get the inserted items. I used to childwindow to show the itemsmthe selected items to be inserted in the parent window. So that i have to refresh the parent grid to show inserted items

If any one knows please help me

-Thanks
0
Chandran Chandran
Top achievements
Rank 1
answered on 03 Sep 2010, 01:08 PM
Hello,
Any ideas?
 To describe my scenario in more detail. Actually i am  having a  main RadGrid from there i invoked First Rad PopUp Window which is also having RadGrid feature. Then from that first pop radwindow i again invoked  Second Popup window which is having list of items in the grid and Insert button.
Once after i checked what are the items need to be inserted and click the Insert button the second Rad PopUp Window need to close and the inserted items need to be shows in my First Rad PopUp Window screen.
So the reflection need to be done in my first rad window against the second radwindow insertion.

I reviewed tha above demo and used the code, but no use, by that code way i could invoke second rad window's needDataSource event. But it is not refreshing to view the inserted items.

Hope now you are able to follow my scenario.If so please help me to catch the solution

-Thanks
0
Chandran Chandran
Top achievements
Rank 1
answered on 03 Sep 2010, 03:49 PM
Hello,

Any suggetions?

-Thanks
0
Chandran Chandran
Top achievements
Rank 1
answered on 07 Sep 2010, 01:16 PM

Hello,

Any opinions would be appreciated       

-Thanks

0
Iana Tsolova
Telerik team
answered on 09 Sep 2010, 02:58 PM
Hi Chandran,

You can handle the InsertCommand of the inner grid. The first argument of this event handler would be the inner grid. Its NamingContainer should be GridEditFormItem which is the edit form of the item you are editing in the outer grid. From them on you can easily access the outer grid and call its Rebind() method. Your code would be similar as the below:

protected void RadGrid2_InsertCommand(object sender, GridCommandEventArgs e)
{
    RadGrid innerGrid = sender as RadGrid;
    GridEditFormItem editedItem = innerGrid.NamingContainer as GridEditFormItem;
    RadGrid outerGrid = editedItem.OwnerTableView.OwnerGrid;
    e.Canceled = true;
    innerGrid.IsItemInserted = false;
    outerGrid.IsItemInserted = false;
    outerGrid.Rebind();
}


Kind regards,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Chandran Chandran
Top achievements
Rank 1
answered on 09 Sep 2010, 05:40 PM
HI Iana

Thanks for your response, I just dont want to call InsertCommand function, becaouse my scenario doesnot meet this. I just want to invoke the ChildPopup by the way of any of button ,then need to refresh the parenet window after closing the child window.

I hope now you are able to catch the point, IF so please do the needful to know the result.

-Thanks
0
Iana Tsolova
Telerik team
answered on 10 Sep 2010, 11:33 AM
Hi Chandran,

The implementation of your scenario will not be much different that the code provided previously. In the Button Click event handler, you need to find the GridEditFormItem, which should be the button NamingContainer. From then on you can use the preceding code.
You might need to put a breakpoint in the Button Click event handler to see which is its NamingContainer.

Kind regards,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
JB
Top achievements
Rank 2
answered on 07 Dec 2010, 04:41 PM
I'm having the same problem with rebinding the data. When I clicked the "Button1" to search and rebind the data, everythig is all good. it's displaying the data that i just search. But the problem is when I clicked any of the "Export" button, the data being exported is the data that was initially loaded in the "Page_Init".

Let me know what am I doing wrong here.

Below is the code for both aspx and code-behind:


Thanks...

Joey

<!-- ASPX code -->
<form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
                                        <table id="tblSearchParameters" runat="server" border="0" cellpadding="5" cellspacing="0"
                                            style="border-right: #e5e7ea thin solid; border-top: #e5e7ea thin solid; border-left: #e5e7ea thin solid;
                                            width: 100%; border-bottom: #e5e7ea thin solid" visible="true">
                                            <tr>
                                                <td colspan="2" style="font-weight: bold; background-color: #e5e7ea">
                                                    Search Parameters&nbsp;</td>
                                                <td id="Td1" runat="server" align="center" colspan="6" style="background-color: #e5e7ea">                                                                                                       
                                                    <asp:Button ID="Button1" runat="server" Text="Search" OnClick="Button1_Click" />
                                                </td>
                                            </tr>
                                            <tr>
                                                <td id="TDPolNumLabel" runat="server" valign="middle" >
                                                    Policy Number:</td>
                                                <td id="TDPolNumEntry" runat="server" valign="middle" >
                                                    <asp:TextBox ID="txtPolNum" runat="server" Width="100px"></asp:TextBox><b>&nbsp; and/or</b></td>
                                                <td id="Td7" runat="server" valign="middle" >
                                                    Last Name:</td>
                                                <td id="Td2" runat="server" valign="middle">
                                                    <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
                                                    <b>and/or</b></td>
                                             </tr>
                                        </table>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                                    <ClientEvents OnRequestStart="onRequestStart" />
                                    <AjaxSettings>
                                        <telerik:AjaxSetting AjaxControlID="RadGrid1">
                                            <UpdatedControls>
                                                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                                            </UpdatedControls>
                                        </telerik:AjaxSetting>
                                    </AjaxSettings>
                                </telerik:RadAjaxManager>
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" AllowSorting="true" GridLines="None" Width="100%" Skin="Sitefinity" ExportSettings-ExportOnlyData="true"
                                    ExportSettings-IgnorePaging="true"
                                    ExportSettings-OpenInNewWindow="true" BorderStyle="Groove" AllowFilteringByColumn="True" OnInit="RadGrid1_Init">
            <ExportSettings HideStructureColumns="True" ExportOnlyData="True" IgnorePaging="True" OpenInNewWindow="True" />
            <MasterTableView CommandItemDisplay="Top" AutoGenerateColumns="false" DataKeyNames="AppNumber" Width="100%">
                <PagerStyle Mode="NumericPages" />
                <Columns>
                    <telerik:GridBoundColumn DataField="AppNumber" HeaderText="Applicant #" 
                        ReadOnly="True" SortExpression="AppNumber" UniqueName="AppNumber" FilterListOptions="VaryByDataTypeAllowCustom">                   
                    </telerik:GridBoundColumn>                          
                    <telerik:GridBoundColumn DataField="AppName" HeaderText="Applicant Name"
                        SortExpression="AppName" UniqueName="AppName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="WritingAgentNum" HeaderText="Writing Agent #" Visible="False"
                        SortExpression="WritingAgentNum" UniqueName="WritingAgentNum" AllowFiltering="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="WritingAgentName" HeaderText="Writing Agent"
                        SortExpression="WritingAgentName" UniqueName="WritingAgentName" AllowFiltering="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="DateRecd" HeaderText="Date Received"
                        SortExpression="DateRecd" UniqueName="DateRecd" AllowFiltering="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="StatusDesc" HeaderText="Status"
                        SortExpression="StatusDesc" UniqueName="StatusDesc" AllowFiltering="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="StatusCode" HeaderText="Code" Visible="False"
                        SortExpression="StatusCode" UniqueName="StatusCode" AllowFiltering="false">
                    </telerik:GridBoundColumn>                                                 
                </Columns>
                <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                                        <CommandItemSettings ShowExportToWordButton="True" ShowExportToExcelButton="True"
                                            ShowExportToCsvButton="True" ShowExportToPdfButton="True"
                                            ShowAddNewRecordButton="False" ExportToPdfText="Export to Pdf"  />
            </MasterTableView>
            <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Sitefinity" EnableImageSprites="True">
                                    </HeaderContextMenu>
                                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
        </telerik:RadGrid>
    </form>


<!-- Code-begind -->
Private Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Init
    RadGrid1.DataSource = clsAgent.Agent_GetApp()    'this returns a datatable
    RadGrid1.DataBind()
End Sub

 

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click        
    RadGrid1.DataSource = Nothing
    RadGrid1.DataSource = clsAgent.Agent_FindApp(txtPolNum.Text, txtLastName.Text)    'this returns a datatable
    RadGrid1.DataBind()
End Sub

 

0
Iana Tsolova
Telerik team
answered on 09 Dec 2010, 01:58 PM
Hello JB,

The described behavior is rather expected.

To overcome it, you can try binding the grid through its NeedDataSource event instead of using simple data-binding. In this case you should move all DataSource assignment to the preceding event as well as the logic from the search button. In the button click event, call the Rebind() method of the grid to rebind it.

Check it out and let me know if further questions arise.

Kind regards,
Iana
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Tayyab Asghar
Top achievements
Rank 1
answered on 20 Dec 2010, 12:03 PM
Hi,
Telerik Grid is still not refreshing. I am doing following steps:
  • using .Net 2.0.
  • set EnableViewState=False which is equivalent to DataSourcePersistenceMode = NoPersistence because it is clearly mentioned  in http://www.telerik.com/help/aspnet/grid/grdviewstateoptimization.html.
  • implemented NeedDataSource event in which binding DataSource
  • See code below

<MasterTableView EnableViewState="False" >

protected void grid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
 this.grid1.DataSource = GetCustomerList();
}
 private void button_Click(object sender, EventArgs e)
        {
        
            grid1.DataSource = null;
            grid1.Rebind();
        }
.
0
Iana Tsolova
Telerik team
answered on 21 Dec 2010, 03:45 PM
Hello Tayyab,

Try modifying the logic in the NeedDataSource event and the Button Click as in the attached demo and see if this works for you.

Regards,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Niska
Top achievements
Rank 1
answered on 20 Mar 2012, 01:05 PM
Hi Iana,

I have this problem too....

I have grid with data and I have to bind new data for this grid.
on the "OnNeedDataSource" event I give the new datasource to the grid
but the binding is not working!!!
after Rebind(),
the gris still show old items!!!


this is very important !!


thanks,
Niska.

0
Shinu
Top achievements
Rank 1
answered on 21 Mar 2012, 08:20 AM
Hi Niska,

I guess you want to bind grid with two DataSources. I have created a sample code snippet which binds the RadGrid with two DataSources in NeedDataSource based on some condition. Here is the code which I tried.

aspx:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="true"onneeddatasource="RadGrid1_NeedDataSource"></telerik:RadGrid>
<asp:Button ID="Button1" runat="server" Text="Orders" onclick="Button1_Click"/>
<asp:Button ID="Button2" runat="server" Text="Employee" onclick="Button2_Click"/>

C#:
string Bind = string.Empty;
public static string connection = WebConfigurationManager.ConnectionString["NorthwindConnectionString3"].ConnectionString;
SqlConnection conn = new SqlConnection(connection);
public SqlCommand SqlCommand = new SqlCommand();
 
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
    if (Bind == "Orders")// RadGrid is Binding with First DataSource
    {
        string selectQuery1 = "select top 10 OrderID,CustomerID from Orders";
        SqlDataAdapter adapter1 = new SqlDataAdapter(selectQuery1, conn);
        DataTable dt1 = new DataTable();
        conn.Open();
        adapter1.Fill(dt1);
        conn.Close();
        RadGrid1.DataSource = dt1;
    }
 
    if (Bind == "Employee")//RadGrid is Binding with Second DataSource
    {
 
        string selectQuery2 = "select top 10 EmployeeID,LastName from Employees";
        SqlDataAdapter adapter2 = new SqlDataAdapter(selectQuery2, conn);
        DataTable dt2 = new DataTable();
        conn.Open();
        adapter2.Fill(dt2);
        conn.Close();
        RadGrid1.DataSource = dt2;
    }
}
protected void Button1_Click(object sender, EventArgs e)
{
    Bind = "Orders";
    RadGrid1.Rebind();
}
protected void Button2_Click(object sender, EventArgs e)
{
    Bind = "Employee";
    RadGrid1.Rebind();
}

Please elaborate your requirement more for further assistance.


Regards,
-Shinu.
0
Niska
Top achievements
Rank 1
answered on 21 Mar 2012, 09:20 AM
thank you,

that was not my problem, I solve it with setting ajax controls.


thanx again anyway
Niska.
0
Robin
Top achievements
Rank 1
answered on 23 Apr 2012, 04:11 PM
Niska, how did you resolved it, because It look like I have the exact same problem you had...

Thanks
Tags
Grid
Asked by
Denny
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Denny
Top achievements
Rank 1
C
Top achievements
Rank 1
Chandran Chandran
Top achievements
Rank 1
Iana Tsolova
Telerik team
JB
Top achievements
Rank 2
Tayyab Asghar
Top achievements
Rank 1
Niska
Top achievements
Rank 1
Shinu
Top achievements
Rank 1
Robin
Top achievements
Rank 1
Share this question
or