This is a migrated thread and some comments may be shown as answers.

[Solved] Filtering Problem Selection out of range exception

3 Answers 164 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 07 Aug 2009, 01:43 PM
Hello Sir

I want to filter the radgrid column but it can give the error selection out of range when i m trying to add 2nd drop downlist search for 2nd column. It works when i add the dropdownlist for single column it will works fine , but in 2nd gives error .


<telerik:GridTemplateColumn HeaderText="Primary Product" DataField="ProdName" UniqueName="ProdName"
                                                                                AllowFiltering="true" AutoPostBackOnFilter="true">
                                                                                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                                                         
                                                                                <ItemTemplate>
                                                                                  <%# DataBinder.Eval(Container.DataItem,"ProdName") %>
                                                                                    <input type="hidden" id="hidPropID" runat="server" value='<%# DataBinder.Eval(Container.DataItem,"Proposal_ID")%>'
                                                                                        name="hidPropID" />
                                                                                    <input type="hidden" id="hidProposalGrpVal" runat="server" value='<%# DataBinder.Eval(Container.DataItem,"ProposalGrpVal")%>'
                                                                                        name="hidProposalGrpVal" />
                                                                                    <input type="hidden" id="hidChecked" runat="server" value='<%# DataBinder.Eval(Container.DataItem,"Checked")%>'
                                                                                        name="hidChecked" />
                                                                                </ItemTemplate>
                                                                             <FilterTemplate>
                                                                                    <telerik:RadComboBox ID="ddlPrimProd" Width="130" DataSourceID="Sqlprimprod" DataTextField="Name"
                                                                                        DataValueField="Name" Height="70" SelectedValue='<%# TryCast(Container, GridItem).OwnerTableView.GetColumn("Name").CurrentFilterValue %>'
                                                                                        runat="server" AppendDataBoundItems="True" Sort="Ascending" SortCaseSensitive="false"
                                                                                         MarkFirstMatch="true" Skin="Black" OnClientSelectedIndexChanged="ProdSelectedIndexChanged">
                                                                                        <Items>
                                                                                            <telerik:RadComboBoxItem Text="< Any Product >" />
                                                                                        </Items>
                                                                                    </telerik:RadComboBox>
                                                                                    <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">

                                                                                        <script type="text/javascript">
                                                                                            function ProdSelectedIndexChanged(sender,args) {
                                                                                            var tableView = $find("<%# TryCast(Container, GridItem).OwnerTableView.ClientID %>");
                                                                                                  if (sender.get_value() != "0")
                                                                                                   {                                                                                               
                                                                                                        tableView.filter("Name",args.get_item().get_value(),"EqualTo");
                                                                                                   }
                                                                                                else {
                                                                                                        tableView.filter("Name", args.get_item().get_value(), "NoFilter");
                                                                                                  }
                                                                                            }
                                                                                        </script>

                                                                                    </telerik:RadScriptBlock>
                                                                                </FilterTemplate></telerik:GridTemplateColumn>


<telerik:GridBoundColumn HeaderText="Crop" DataField="CropName" AllowFiltering="true"
                                                                                UniqueName="Name" AutoPostBackOnFilter="true" SortExpression="CropName">
                                                                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"></HeaderStyle>
                                                                               
                                                                                <%--<ItemStyle Width="10%" />--%>
                                                                               <%--<FilterTemplate >
                                                                                <telerik:RadComboBox ID="ddlcrop" Width="130" DataTextField="CropName" ShowToggleImage ="false" EnableLoadOnDemand = "true"
                                                                                    DataValueField="CropName" runat="server" AppendDataBoundItems="true" markFirstMatch="true" Skin="Black"></telerik:RadComboBox>
                                                                                </FilterTemplate>--%>                  
                                                                                                                                                              
                                                                                <FilterTemplate>
                                                                                <telerik:RadComboBox ID="ddlcrop" Width="130" DataSourceID="SqlDataSource1" DataTextField="Name"
                                                                                    DataValueField="Name" Height="90" SelectedValue='<%# TryCast(Container, GridItem).OwnerTableView.GetColumn("Name").CurrentFilterValue %>'
                                                                                    runat="server" AppendDataBoundItems="true" OnClientSelectedIndexChanged="SelectedIndexChanged"
                                                                                    MarkFirstMatch="true" Skin="Black">
                                                                                    <Items>
                                                                                        <telerik:RadComboBoxItem Text=" <  Every  >" />
                                                                                    </Items>
                                                                                </telerik:RadComboBox>
                                                                                <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

                                                                                    <script type="text/javascript">
                                                                                            function SelectedIndexChanged(sender,args) {
                                                                                            var tableView = $find("<%# TryCast(Container, GridItem).OwnerTableView.ClientID %>");
                                                                                                  if (sender.get_value() != "0")
                                                                                                   {                                                                                                
                                                                                                        tableView.filter("Name",args.get_item().get_value(),"Contains");
                                                                                                   }
                                                                                                else {
                                                                                                        tableView.filter("Name", args.get_item().get_value(), "NoFilter");
                                                                                                  }
                                                                                            }
                                                                                    </script>

                                                                                </telerik:RadScriptBlock>
                                                                            </FilterTemplate>
                                                                            </telerik:GridBoundColumn>



It gives exception when page is postback

  dgProposals.DataBind()

I m confuse why it happen bcuz it works when i trying for single column it will filter out proper , but when i add the the combobox for another column it gives exception.


The datasources are different ;


<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:GoConnectionString %>"
        SelectCommand="SELECT [ID], [Name] FROM [Crop]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="sqlprimprod" runat="server" ConnectionString="<%$ ConnectionStrings:GoConnectionString %>"
        SelectCommand="SELECT [Name] FROM [QryProdTN] ORDER BY [Name]"></asp:SqlDataSource>


Help Me urgent sir, Its very urgnet need

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 07 Aug 2009, 02:19 PM
Hi Rahul,

Could you please confirm that you are not binding the Grid through simple data-binding
calling DataBind()?
Additionally, please review the following live demo where three columns with dropdown filters are working properly and see what is the difference in your case.
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx

All the best,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Rahul
Top achievements
Rank 1
answered on 10 Aug 2009, 05:51 AM
Hello Sir


My problem still same, I m trying same way but it creating same prolblem

"Selection out of range Parameter name: value"

Why this happen when m trying to add the 2 radcombo. It works fine when 1 combobox. ?


Please help me urgent.

Thnaks

0
Pavlina
Telerik team
answered on 11 Aug 2009, 04:08 PM
Hello Rahul,

I am afraid that the provided information is not enough to determine what is causing the problem.
If the issue persists, you can open a formal support ticket, and supply a small project, demonstrating the issue you are facing, for additional testing and debugging.

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Rahul
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Rahul
Top achievements
Rank 1
Share this question
or