master detail grid with mysql - based on telerik samples wont work

4 posts, 0 answers
  1. Jon
    Jon avatar
    24 posts
    Member since:
    Apr 2009

    Posted 03 Oct 2011 Link to this post

    Took the following sample code:

    http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectedvalue/defaultvb.aspx

    And adapted it to mysql and my dB, can get grids one and two working as they should but grid 3 will not show any data. what am i doing wrong?
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
     
     
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <ajaxsettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid3" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadGrid2">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid2" />
                        <telerik:AjaxUpdatedControl ControlID="RadGrid3" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="RadGrid3">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid3" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </ajaxsettings>
        </telerik:RadAjaxManager>
         
        <strong>States:</strong>
        <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true"
            PageSize="5" DataSourceID="SqlDataSource1" GridLines="None" width="95%">
            <clientsettings allowkeyboardnavigation="true" enablepostbackonrowclick="true">
                <Selecting AllowRowSelect="true" />
            </clientsettings>
            <mastertableview datakeynames="State" />
            <pagerstyle mode="NextPrevAndNumeric" />
        </telerik:RadGrid><br /><br />
         
        <strong>Companies:</strong>
        <telerik:RadGrid ID="RadGrid2" ShowStatusBar="true" runat="server"
            AllowPaging="True" PageSize="5" DataSourceID="SqlDataSource2" GridLines="None"
            width="95%" HorizontalAlign="NotSet">
            <mastertableview width="100%" datakeynames="State"
                datasourceid="SqlDataSource2">
            </mastertableview>
             <clientsettings allowkeyboardnavigation="true" enablepostbackonrowclick="true">
                <Selecting AllowRowSelect="true" />
            </clientsettings>
            <pagerstyle mode="NextPrevAndNumeric" />
        </telerik:RadGrid><br /><br />
         
        <strong>Records:</strong>
        <telerik:RadGrid ID="RadGrid3" ShowStatusBar="true" runat="server"
            AllowPaging="True" PageSize="5" DataSourceID="SqlDataSource3" GridLines="None"
            width="95%" HorizontalAlign="NotSet">
            <mastertableview width="100%"
                datasourceid="SqlDataSource3">
            </mastertableview>
             <clientsettings allowkeyboardnavigation="true" enablepostbackonrowclick="true">
                <Selecting AllowRowSelect="true" />
            </clientsettings>
            <pagerstyle mode="NextPrevAndNumeric" />
        </telerik:RadGrid>
     
     
        <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:connex %>"
            ProviderName="MySql.Data.MySqlClient" SelectCommand="
                SELECT EMPLOYER_STATE AS State,
                COUNT(EMPLOYER_STATE) as 'Total Filings'
                FROM y2010
                GROUP BY EMPLOYER_STATE
                ORDER BY COUNT(EMPLOYER_STATE) desc"
            runat="server"></asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:connex %>"
            ProviderName="MySql.Data.MySqlClient" SelectCommand="
            SELECT EMPLOYER_NAME AS Employer,
            EMPLOYER_STATE AS State,
            COUNT(EMPLOYER_NAME) as 'Total Filings'
            FROM y2010
            WHERE EMPLOYER_STATE=@state
            GROUP BY EMPLOYER_NAME
            ORDER BY COUNT(EMPLOYER_STATE) desc"
            runat="server">
            <SelectParameters>
             <asp:ControlParameter ControlID="RadGrid1" DefaultValue="CA" Name="State"
             PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource3" ConnectionString="<%$ ConnectionStrings:connex %>"
            ProviderName="<%$ ConnectionStrings:connex.ProviderName %>"
            SelectCommand="SELECT SOC_NAME, EMPLOYER_NAME AS Employer
            FROM y2010 WHERE (EMPLOYER_NAME = @Employer)"
            runat="server">
            <SelectParameters>
             <asp:ControlParameter ControlID="RadGrid2" name="Employer"
             PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>


  2. Marin
    Admin
    Marin avatar
    1045 posts

    Posted 06 Oct 2011 Link to this post

    Hello Jon,

     You can try setting DefaultValue for the SelectParameter in the third SqlDataSource control:

    <asp:SqlDataSource ID="SqlDataSource3" ConnectionString="<%$ ConnectionStrings:connex %>"
            ProviderName="<%$ ConnectionStrings:connex.ProviderName %>"
            SelectCommand="SELECT SOC_NAME, EMPLOYER_NAME AS Employer
            FROM y2010 WHERE (EMPLOYER_NAME = @Employer)"
            runat="server">
            <SelectParameters>
             <asp:ControlParameter ControlID="RadGrid2" name="Employer" DefaultValue = "default value"
             PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
        </asp:SqlDataSource>

    and also setting DataKeyNames for the third grid.Regards,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jon
    Jon avatar
    24 posts
    Member since:
    Apr 2009

    Posted 06 Oct 2011 Link to this post

    what would i set as the data key name
    and what would i put as the defualt value
  5. Marin
    Admin
    Marin avatar
    1045 posts

    Posted 07 Oct 2011 Link to this post

    Hello Jon,

     You should set as DataKeyName a unique field in your table (e.g. SOC_NAME or EMPLOYER_NAME). As a default value you should set any existing value of the EMPLOYER_NAME field from the y2010 table. Similar to the way you did with the State select parameter in the SqlDataSource2 control.

    Greetings,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top