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

Binding RadCombobox with RadGrid

1 Answer 142 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sompop
Top achievements
Rank 1
Sompop asked on 25 Sep 2008, 05:15 PM
Hi there,

I would like to know how to bind rad combo with rad grid.
Here is my situation.

1. I have nothing on .aspx.cs
2. When I click edit on the grid, I can see the edit form that I made and I also see data on the rad combobox that I made. HOWEVER, the rad combobox does not show all records that I linked the rad combobox with datasourceid="SQLDSContact" so I cannot update to other people. Please educate me how to do this.

Thank You


Below is my code


<rad:RadGrid ID="RadGrid1" runat="server" AllowFilteringByColumn="True" AllowPaging="True"
        AllowSorting="True" DataSourceID="SqlDataSource1" EnableAJAX="True" GridLines="None"
        AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true">
        <MasterTableView AutoGenerateColumns="False" DataKeyNames="equipmentGuid" DataSourceID="SqlDataSource1">
            <RowIndicatorColumn Visible="False">
                <HeaderStyle Width="20px" />
            </RowIndicatorColumn>
            <ExpandCollapseColumn Resizable="False" Visible="False">
                <HeaderStyle Width="20px" />
            </ExpandCollapseColumn>
            <Columns>
                <rad:GridEditCommandColumn>
                </rad:GridEditCommandColumn>
                <rad:GridBoundColumn DataField="CustomerControlNo" HeaderText="Control No" SortExpression="CustomerControlNo"
                    UniqueName="CustomerControlNo">
                </rad:GridBoundColumn>                
                <rad:GridBoundColumn DataField="equipmentGuid" DataType="System.Guid" HeaderText="equipmentGuid"
                    ReadOnly="True" SortExpression="equipmentGuid" UniqueName="equipmentGuid" Visible="false">
                </rad:GridBoundColumn>
            </Columns>
            <EditFormSettings EditFormType="Template">
                    <FormTemplate>
                        <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
                            style="border-collapse: collapse;background:white;">
                            <tr class="EditFormHeader">
                                <td colspan="2" style="font-size: small">
                                    <b>Asset Details</b></td>
                            </tr>
                            <tr>
                                <td>
                                    <table id="Table3" cellspacing="1" cellpadding="1" width="250" border="0" class="module">
                                        <tr>
                                            <td>Contact
                                            </td>
                                            <td>
                                                <radC:RadComboBox ID="rcbContact" runat="server" DataSourceID="SQLDSContact" DataValueField="contactGuid" DataTextField="contactName" Value='<%# Bind("contactGuid") %>' Text='<%# Bind("contactName") %>'>
                                                </radC:RadComboBox>
                                            </td>
                                        </tr>                                        
                                        <tr>
                                            <td>
                                                Control #:</td>
                                            <td>
                                                <asp:TextBox ID="txtCCNo" runat="server" Text='<%# Bind( "customerControlNo" ) %>'>
                                                </asp:TextBox></td>
                                        </tr>                                        
                                    </table>
                                </td>                                
                            </tr>                            
                            <tr>
                                <td align="right" colspan="2">
                                    <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                        runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                    </asp:Button>&nbsp;
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
CommandName="Cancel"></asp:Button></td>
                            </tr>
                        </table>
                    </FormTemplate>
                </EditFormSettings>
        </MasterTableView>
        <ClientSettings>
            <Selecting AllowRowSelect="true" />
            <ClientEvents OnRowSelected="RowSelected" />
        </ClientSettings>
    </rad:RadGrid><br />
    
    
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:uscalConnectionString %>"
        SelectCommand="ViewAsset" SelectCommandType="StoredProcedure" >
        <UpdateParameters>
                <asp:Parameter Name="equipmentGuid" Type="empty" />
                <asp:Parameter Name="customerControlNo" Type="String" />
                <asp:Parameter Name="serialNo" Type="String" />
                <asp:Parameter Name="manufacturer" Type="String" />
                <asp:Parameter Name="model" Type="String" />
                <asp:Parameter Name="description" Type="String" />
        </UpdateParameters>             
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SQLDSContact" runat="server" ConnectionString="<%$ ConnectionStrings:uscalConnectionString %>"
    SelectCommand="SELECT c.contactGuid, c.firstName + ' ' + c.lastName AS contactName FROM Contacts c, Equipment e WHERE e.contactGuid = c.contactGuid">
    <SelectParameters>
        <asp:ControlParameter ControlID="RadGrid1" Name="equipmentGuid" PropertyName="SelectedValue" Type="empty" />
    </SelectParameters>
    </asp:SqlDataSource>



1 Answer, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 26 Sep 2008, 08:26 AM
Hi Kthirapatpibul,

You may find this online example helpful. It demonstrates how to use RadComboBox in RadGrid.

Best wishes,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ComboBox
Asked by
Sompop
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Share this question
or