1

I have a RadGrid which on RowClick should send a specific value to the server. Due to the nature of the page all events are handled Server Side. My -Radgrid1- uses a default "select" all sqldatasource when first accessing the page and then, you can filter RadGrid1 items by clicking on another RadGridAnother. which also has a list of different categories.

What happens is : 1. Row is clicked 2. radgrid1_ItemCommand(...,...) is executed.

Code Below changed to actual after Edit :

protected void MenuKampionati_ItemClick(object sender, RadMenuEventArgs e)
{
    Case = 2;
    Arg1 = "%%";
    Arg2 = e.Item.Value;
    string query = "EXECUTE get_ndeshje_kot31 " + Case.ToString() + ", '" + Arg1 + "', '" + Arg2 + "', 0";
    SqlDataSource MyDataSource = new SqlDataSource(ConfigurationManager.ConnectionStrings["basteConnectionString"].ConnectionString, query);
    this.GridNdeshjet.DataSource = MyDataSource;
    this.GridNdeshjet.DataBind();
}

3. Page "refreshes" and RadGrid1 has the Old values in it + the label has default text of test.

I have read all Telerik API regarding this matter, and tried previuos solutions in vain. Is there something I am missing? or forgetting to do? Has anyone any idea why this might be happening?

Regarding AJAX, my manager has instructed me not to "AJAX" this page. Hope my english is good enough for this problem.

Edit : I got a PM about my query, i have already tested it in sqlserver management studio and it is fully functional. I am now adding aspx code of the div that contains this controls, outside there are labels, some aspbutton and nothing more not related to the contents of this div.

Second Edit, Previous Grids were changed to RadMenu. Codebehind is still the same, just associated with the new Menu.

      <div>
 <table>
    <tr>

        <td><asp:UpdatePanel ID="panelGetTeGjitha"  runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" >
                <ContentTemplate>
                <telerik:RadMenu ID="MenuKategoria" runat="server" DataSourceID="GetKategoriaDataSource" 
                        DataTextField="kategoria" DataValueField="vlera" Flow="Vertical" 
                            DataFieldID="kategoria"
                        onitemclick="MenuKategoria_ItemClick">
                </telerik:RadMenu>
                    <asp:SqlDataSource ID="GetKategoriaDataSource" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:basteConnectionString %>" 
                        SelectCommand="Get_Kategorite" SelectCommandType="StoredProcedure">
                        <SelectParameters>
                            <asp:SessionParameter DefaultValue="0" Name="Country" SessionField="country" 
                                Type="Int32" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                </ContentTemplate>
            </asp:UpdatePanel></td>
        <td><asp:UpdatePanel ID="panelGetKampionati"  runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" >
                <ContentTemplate>
                    <telerik:RadMenu ID="MenuKampionati" runat="server" DataSourceID="GetKampionatiDataSource" 
                        DataTextField="kampionati" DataValueField="kampionati" Flow="Vertical" 
                            DataFieldID="kategoria" onitemclick="MenuKampionati_ItemClick" >
                </telerik:RadMenu>
                    <asp:SqlDataSource ID="GetKampionatiDataSource" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:basteConnectionString %>" SelectCommand="SELECT kampionati FROM ndeshje (NOLOCK) 
            WHERE ((data &gt; getdate() and ndeshje_id_live IS NULL) OR (data &lt; getdate() AND data_hapjes &gt; getdate()                                  AND ndeshje_id_live IS NOT NULL))
            AND bllokuar = '0' AND live = 0 
            GROUP BY kampionati ORDER by kampionati"></asp:SqlDataSource>
                <telerik:RadGrid ID="GridNdeshjet" runat="server" GridLines="None" 
                     onneeddatasource="GridNdeshjet_NeedDataSource1">
                </telerik:RadGrid>
                </ContentTemplate>
            </asp:UpdatePanel></td>
        <td><asp:UpdatePanel ID="panelGetNdeshje"  runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" >
                <ContentTemplate>
                    <telerik:RadMenu ID="MenuNdeshjeLive" runat="server" DataSourceID="GetNdeshjeLiveDataSource" 
                        DataTextField="Home" DataValueField="Home" Flow="Vertical" 
                            DataFieldID="Home" onitemclick="MenuKampionati_ItemClick" >
                </telerik:RadMenu>
                    <asp:SqlDataSource ID="GetNdeshjeLiveDataSource" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:basteConnectionString %>" SelectCommand="SELECT MAX(Home) AS Home, MAX(Away) AS Away FROM ndeshje (NOLOCK) 
         WHERE(Data &lt; getdate() AND data_hapjes &gt; getdate() AND ndeshje_id_live IS NOT null AND live = 1) 
         AND bllokuar = '0' GROUP BY Home, Away ORDER BY Home, Away"></asp:SqlDataSource>
                </ContentTemplate>
            </asp:UpdatePanel></td>
    </tr>
</table>

Tony L.
  • 17,638
  • 8
  • 69
  • 66
stevenll
  • 1,025
  • 12
  • 29

1 Answers1

0

Let me know if any concern.

  <asp:UpdatePanel ID="panelGetKampionati" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <telerik:RadMenu ID="MenuKampionati" runat="server" DataTextField="Name" DataValueField="ID"
                            Flow="Vertical" DataFieldID="ID" OnItemClick="MenuKampionati_ItemClick">
                        </telerik:RadMenu>
                        <telerik:RadGrid ID="GridNdeshjet" runat="server" GridLines="None" OnNeedDataSource="GridNdeshjet_NeedDataSource1">
                        </telerik:RadGrid>
                    </ContentTemplate>
                </asp:UpdatePanel>

..........

  protected void MenuKampionati_ItemClick(object sender, RadMenuEventArgs e)
{

    GridNdeshjet.Rebind();
}

protected void GridNdeshjet_NeedDataSource1(object sender, GridNeedDataSourceEventArgs e)
{

    string strID = string.Empty; // just For Test


    if (MenuKampionati.SelectedItem != null)
    {
        // Get Selected Records  as per item selected in RadMenu

        //Case = 2;
        //Arg1 = "%%";
        string Arg2 = MenuKampionati.SelectedItem.Value;
        //string query = "EXECUTE get_ndeshje_kot31 " + Case.ToString() + ", '" + Arg1 + "', '" + Arg2 + "', 0";
        //SqlDataSource MyDataSource = new SqlDataSource(ConfigurationManager.ConnectionStrings["basteConnection
        strID = MenuKampionati.SelectedItem.Value; // just For Test
    }
    else
    {
        // Get All records From DB
    }


    // just For Test
    dynamic data = new[] {
            new { ID = 1, Name ="Name" + strID},
            new { ID = 2, Name ="Name"+ strID},
            new { ID = 3, Name ="Name"+ strID},
            new { ID = 4, Name ="Name"+ strID},
            new { ID = 5, Name ="Name"+ strID},
            new { ID = 6, Name = "Name"+ strID}
        };


    GridNdeshjet.DataSource = data;
}
Jayesh Goyani
  • 11,008
  • 11
  • 30
  • 50
  • Hello jayesh, thank you for replying. After i saw your answer i did noticed that my two grids were in different UpdatePanel-s but i put them both in the same UpdatePanel, run the test but it didn't work. BUT i must add, that after moving them in the same UpdatePanel, after PostBack RadGrid1 had the old values, i accidentally hit the refresh button and it showed me the filtered data this time. I think i am missing some type of setting here, any idea? – stevenll May 30 '12 at 12:01
  • Can you please provide your aspx page code? So we can able to solve the issue. – Jayesh Goyani May 30 '12 at 12:37
  • I updated the code above, i left the grid i want to update on the same UpdatePanel as the RadMenu (now) which should update it. – stevenll May 30 '12 at 13:25
  • Hello, your method works fine, but again the change doesn't show after Postback it shows if you refresh the page. I'll have to redo this from scratch i think. Thanks a lot for your time. – stevenll May 31 '12 at 09:06
  • i have checked with your requirement on above code its working correctly. please check above code in separate page and let me know its working or not. – Jayesh Goyani May 31 '12 at 16:55
  • Hello, i removed all update panels and it worked. I was recommended that only when my project was entirely done i could use RadAjaxManager to ajaxify the page. – stevenll Jun 02 '12 at 23:03