1

我有一个 RadGrid,它在 RowClick 上应该向服务器发送一个特定的值。由于页面的性质,所有事件都在服务器端处理。我的 -Radgrid1- 在第一次访问页面时使用默认的“选择”所有 sqldatasource,然后,您可以通过单击另一个 RadGridAnother 来过滤 RadGrid1 项目。其中也有一个不同类别的列表。

会发生什么: 1. 单击行 2. 执行 radgrid1_ItemCommand(...,...) 。

下面的代码在编辑后更改为实际代码:

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. 页面“刷新”并且 RadGrid1 中包含旧值 + 标签具有默认测试文本。

我已经阅读了有关此问题的所有 Telerik API,并徒劳地尝试了 previuos 解决方案。有什么我想念的吗?还是忘记做?有谁知道为什么会发生这种情况?

关于 AJAX,我的经理指示我不要“AJAX”这个页面。希望我的英语足够好解决这个问题。

编辑:我收到了关于我的查询的 PM,我已经在 sqlserver 管理工作室中对其进行了测试,它功能齐全。我现在添加包含此控件的 div 的 aspx 代码,外面有标签、一些 aspbutton,仅此而已与此 div 的内容无关。

第二次编辑,以前的网格更改为 RadMenu。Codebehind 还是一样的,只是与新的 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>

4

1 回答 1

0

让我知道是否有任何问题。

  <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;
}
于 2012-05-30T10:59:50.293 回答