Question

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>

Was it helpful?

Solution

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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top