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

Two Dropdownlists in One GridTemplateColumn

3 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rimantas
Top achievements
Rank 1
Rimantas asked on 16 Sep 2008, 06:57 AM
Hi,

I have two dropdownlists in one GridTemplateColumn. When I changed selected index in Vietove_Id DropDownList, data chenged for all Gatve_Id DropdDownLists, not for one

excuse me for my english

<telerik:RadGrid ID="ButaiRadGrid" runat="server"  
GridLines="None" AutoGenerateColumns="False" Skin="Hay"
<MasterTableView> 
     <Columns> 
            <telerik:GridTemplateColumn UniqueName="RowNumber" HeaderText = "Eil.Nr."
                <ItemTemplate> 
                    <asp:Label runat = "server" ID = "lblRowNumber"></asp:Label> 
                </ItemTemplate> 
            </telerik:GridTemplateColumn> 
            <telerik:GridTemplateColumn UniqueName="ButoNr" HeaderText = "Buto Nr."
                <ItemTemplate> 
                    <asp:TextBox ID="tbButoNr" runat="server" Text='<%# Bind("ButoNr") %>'
                    </asp:TextBox> 
                </ItemTemplate> 
            </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn UniqueName="MoketojoKodas" HeaderText = "Mokėtojo kodas"
                    <ItemTemplate> 
                        <asp:TextBox ID="tbMoketojoKodas" runat="server" Text = '<%#bind("MoketojoKodas") %>'></asp:TextBox> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                    <telerik:GridTemplateColumn UniqueName="ElPastas" HeaderText = "El. paštas"
                        <ItemTemplate><asp:TextBox ID="tbElPastas" runat="server" Text = '<%#Bind("ElPastas") %>'></asp:TextBox> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                    <telerik:GridTemplateColumn UniqueName="Telefonas" HeaderText = "Telefonas"><ItemTemplate> 
                        <asp:TextBox ID="tbTelefonas" runat="server" Text = '<%#Bind("Telefonas") %>'></asp:TextBox> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridTemplateColumn UniqueName="AdresasCheckBox" HeaderText = "Vietinis adresas?"
                    <ItemTemplate> 
                        <asp:CheckBox ID="cbAdresas" runat="server" Checked = '<%#Bind("AdresasCheckBox") %>' AutoPostBack = "true"/> 
                        <asp:Table ID = "AdresTable" runat="server"
                           <asp:TableRow> 
                               <asp:TableCell> 
                                    <asp:Label ID="VietoveLabel" runat="server" Text="Vietovė"></asp:Label> 
                                </asp:TableCell> 
                                <asp:TableCell> 
                                     <asp:DropDownList ID="vietove_Id" runat="server" 
                                        DataSourceID = "VietovesSqlDataSource" DataValueField = "Locality_Id"  
                                        DataTextField = "Name" AutoPostBack="True"  
                                        SelectedValue='<%# Bind("Vietove") %>' OnSelectedIndexChanged = "vietove_Id_SelectedIndexChanged" > 
                                    </asp:DropDownList> 
                                </asp:TableCell> 
                            </asp:TableRow> 
                            <asp:TableRow> 
                                <asp:TableCell> 
                                    <asp:Label ID="gatveLabel" runat="server" Text="Gatvė:"></asp:Label> 
                                </asp:TableCell> 
                                <asp:TableCell> 
                                    <asp:DropDownList ID="gatve_Id" runat="server" 
                                        DataSourceID = "GatvesSqlDataSource" DataValueField = "Street_Id"  
                                        DataTextField = "Name" 
                                        ondatabound="gatve_Id_DataBound"
                                    </asp:DropDownList>   
                                </asp:TableCell> 
                            </asp:TableRow> 
                        </asp:Table> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
                <telerik:GridButtonColumn CommandName="Delete" Text="Ištrinti" UniqueName="Delete"></telerik:GridButtonColumn> 
            </Columns> 
        <EditFormSettings > 
            <EditColumn UniqueName="EditCommandColumn1"></EditColumn> 
        </EditFormSettings> 
    </MasterTableView>  
</telerik:RadGrid> 

Protected Sub populateDropDownItems(ByVal Streets As DropDownList, ByVal Locality_id As String
        StreetsSqlDataSource.SelectCommand = String.Format("exec Get_Streets @Locality_Id = {0}", Locality_id) 
        Streets.Items.Clear() 
        Streets.DataSourceID = "StreetsSqlDataSource" 
        Streets.DataBind() 
    End Sub 
 
    Protected Sub vietove_Id_SelectedIndexChanged(ByVal sender As ObjectByVal e As System.EventArgs) 
        Dim Item As GridDataItem = TryCast(TryCast(sender, DropDownList).NamingContainer, GridDataItem) 
        Dim vietove As DropDownList = Item.FindControl("Vietove_Id"
        Dim gatve As DropDownList = Item.FindControl("Gatve_Id"
        Dim telefonas As TextBox = Item.FindControl("tbTelefonas"
        telefonas.Text = vietove.SelectedItem.Text 
        Dim locality_id As String = vietove.SelectedValue 
        populateDropDownItems(gatve, locality_id) 
    End Sub 
 
    Protected Sub ButaiRadGrid_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles ButaiRadGrid.PreRender 
        Dim properties As New DataTable 
        properties = Session("Properties_Table"
        Dim i As Integer = 0 
        For Each item As GridDataItem In ButaiRadGrid.MasterTableView.Items 
            Dim cbAdresas As CheckBox = CType(item.FindControl("cbAdresas"), CheckBox) 
            Dim AdresTable As Table = CType(item.FindControl("AdresTable"), Table) 
            If cbAdresas.Checked Then 
                AdresTable.Visible = False 
            Else 
                AdresTable.Visible = True 
            End If 
            i = i + 1 
        Next 
        Session("Properites_Id") = properties 
        ButaiRadGrid.DataSource = properties 
    End Sub 

thanks!

3 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 17 Sep 2008, 03:10 PM
Hello Rimantas,

I followed your scenario in order to replicate the issue but no avail. Please find the attached sample and try it on your end. Let me know what differs in your case.

Greetings,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Rimantas
Top achievements
Rank 1
answered on 18 Sep 2008, 07:15 AM
Thank you very much Iana, for your replay.

When i looking  to code, which you send, I found the problem.

When I changed select string of StreetSqlDataSource  It changed for all DropDownLists because all DropDownLists belongs to one StreetDataSource.

In addition, excuse me for my english :)

0
Iana Tsolova
Telerik team
answered on 18 Sep 2008, 09:30 AM
Hi Rimantas,

I am happy to hear you found the problem and solved your case.

Let me know if you need further assistance.

Regards,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Rimantas
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Rimantas
Top achievements
Rank 1
Share this question
or