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

combobox in radgrid

3 Answers 169 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Toshiyuki
Top achievements
Rank 1
Toshiyuki asked on 21 Jan 2011, 03:59 PM

Hi,
I found a problem on the radcombobox on my radgrid. If I selected couple of values from the combobox by using autocomplete separator & click update, it didn't work at all. If I selected only one value from the combobox, it could be updated properly on the table on my sql database.
Can any of you tell me what is wrong ?

<%@ Page Language="VB" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
       
       
   
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
         <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadGrid1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                 <telerik:AjaxSetting AjaxControlID="RadCombobox1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
          </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server"
            Transparency="50">
            <div style="background-color: #FFFFFF; height: 100%;">
            <asp:Image ID="Image1" runat="server" ImageUrl="loading1.gif"
                    AlternateText="loading" ImageAlign="AbsMiddle" />
        </div>

         </telerik:RadAjaxLoadingPanel>
        
       
        <br />
        <br />
        <telerik:RadComboBox ID="RadComboBox1" Runat="server"
            DataSourceID="SqlDataSource3" DataTextField="F5" DataValueField="F5"
            Height="20px" MaxHeight="500px" Width="412px" AutoPostBack="True"
            Skin="WebBlue" AppendDataBoundItems="True">
            <Items>
            <telerik:RadComboBoxItem value="0", Text="Please select your name..." />
            </Items>
        </telerik:RadComboBox>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server"
            ConnectionString="<%$ ConnectionStrings:usagelogConnectionString %>"
            SelectCommand="SELECT DISTINCT F5 FROM OriginalReport"></asp:SqlDataSource>
        <br />
        <br />
       
              
       
       
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
                    GridLines="None" Skin="WebBlue" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" >
<HeaderContextMenu CssClass="GridContextMenu GridContextMenu_WebBlue"></HeaderContextMenu>

                    <MasterTableView  DataKeyNames="F1"
                        DataSourceID="SqlDataSource1" CommandItemDisplay="TopAndBottom">

<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>

<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
                        <Columns>
                         <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderText="Edit" >
                              <HeaderStyle Width="10px" />
                            </telerik:GridEditCommandColumn>
                            <telerik:GridBoundColumn DataField="F1" DataType="System.Int32" HeaderText="ID#"
                                ReadOnly="True" SortExpression="F1" UniqueName="F1"
                                FilterControlAltText="Filter F1 column">
                            </telerik:GridBoundColumn>
                            <telerik:GridDateTimeColumn DataField="F2"
                                FilterControlAltText="Filter F2 column" HeaderText="Publication Date"
                                UniqueName="F2">
                            </telerik:GridDateTimeColumn>
                            <telerik:GridBoundColumn DataField="F3" HeaderText="DocID" SortExpression="F3"
                                UniqueName="F3" FilterControlAltText="Filter F3 column">
                            </telerik:GridBoundColumn>
                            <telerik:GridHTMLEditorColumn DataField="F4"
                                FilterControlAltText="Filter F4 column" HeaderText="Report Title"
                                UniqueName="F4">
                            </telerik:GridHTMLEditorColumn>
                            <telerik:GridBoundColumn DataField="F5" FilterControlAltText="Filter F5 column"
                                HeaderText="Written by..." SortExpression="F5" UniqueName="F5">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="F6" FilterControlAltText="Filter F6 column"
                                HeaderText="Written by..." SortExpression="F6" UniqueName="F6">
                            </telerik:GridBoundColumn>
                            <telerik:GridDropDownColumn DataField="F7" DataSourceID="SqlDataSource5"
                                FilterControlAltText="Filter F7 column" HeaderText="Content Type"
                                ListTextField="F1" ListValueField="F1" UniqueName="F7">
                            </telerik:GridDropDownColumn>
                            <telerik:GridDropDownColumn DataField="F8" DataSourceID="SqlDataSource4"
                                FilterControlAltText="Filter F8 column" HeaderText="Industry"
                                ListTextField="F1" ListValueField="F1" UniqueName="F8">
                            </telerik:GridDropDownColumn>
                            <telerik:GridTemplateColumn DataField="F9"
                                FilterControlAltText="Filter F9 column" HeaderText="Global Vendor"
                                UniqueName="F9">
                                <EditItemTemplate>
                                    <telerik:RadComboBox ID="F9RadComboBox" runat="server" AllowCustomText="True"
                                        AutoCompleteSeparator=";" DataSourceID="SqlDataSource2" DataTextField="F1"
                                        DataValueField="F1" Height="19px" MarkFirstMatch="True"
                                        SelectedValue='<%# Bind("F9") %>' Width="504px"  MaxHeight="500px" >
                                    </telerik:RadComboBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="F9Label" runat="server" Text='<%# Eval("F9") %>'></asp:Label>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn DataField="F10" FilterControlAltText="Filter F10 column"
                                HeaderText="Vendor manual input" SortExpression="F10" UniqueName="F10">
                            </telerik:GridBoundColumn>
                        </Columns>
                        <EditFormSettings>
                            <EditColumn UniqueName="EditCommandColumn1" >
                            </EditColumn>
                        </EditFormSettings>
                        <CommandItemSettings ShowExportToCsvButton="True" ShowExportToExcelButton="True"
                            ShowExportToPdfButton="True" ShowExportToWordButton="True" />
                    </MasterTableView>

<FilterMenu EnableImageSprites="False"></FilterMenu>
                </telerik:RadGrid>
               
               
               
                
                <br />
                <br />
       

       
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:usagelogConnectionString %>"
                    DeleteCommand="DELETE FROM [OriginalReport] WHERE [F1] = @F1"
                    InsertCommand="INSERT INTO [OriginalReport] ([F2], [F3], [F4], [F5], [F6], [F7], [F8], [F9], [F10]) VALUES (@F2, @F3, @F4, @F5, @F6, @F7, @F8, @F9, @F10)"
                    SelectCommand="SELECT [F1], [F2], [F3], [F4], [F5], [F6], [F7], [F8], [F9], [F10] FROM [OriginalReport] WHERE ([F5] = @F5)"
                   
           
            UpdateCommand="UPDATE [OriginalReport] SET [F2] = @F2, [F3] = @F3, [F4] = @F4, [F5] = @F5, [F6] = @F6, [F7] = @F7, [F8] = @F8, [F9] = @F9, [F10] = @F10 WHERE [F1] = @F1">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="RadComboBox1" Name="F5"
                            PropertyName="SelectedValue" Type="String" />
                    </SelectParameters>
                    <DeleteParameters>
                        <asp:Parameter Name="F1" Type="Int32" />
                    </DeleteParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="F2" Type="DateTime" />
                        <asp:Parameter Name="F3" Type="String" />
                        <asp:Parameter Name="F4" Type="String" />
                        <asp:Parameter Name="F5" Type="String" />
                        <asp:Parameter Name="F6" Type="String" />
                        <asp:Parameter Name="F7" Type="String" />
                        <asp:Parameter Name="F8" Type="String" />
                        <asp:Parameter Name="F9" Type="String" />
                        <asp:Parameter Name="F10" Type="String" />
                        <asp:Parameter Name="F1" Type="Int32" />
                    </UpdateParameters>
                    <InsertParameters>
                        <asp:Parameter Name="F2" Type="DateTime" />
                        <asp:Parameter Name="F3" Type="String" />
                        <asp:Parameter Name="F4" Type="String" />
                        <asp:Parameter Name="F5" Type="String" />
                        <asp:Parameter Name="F6" Type="String" />
                        <asp:Parameter Name="F7" Type="String" />
                        <asp:Parameter Name="F8" Type="String" />
                        <asp:Parameter Name="F9" Type="String" />
                        <asp:Parameter Name="F10" Type="String" />
                    </InsertParameters>
                </asp:SqlDataSource>
              
    </div>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server"
        ConnectionString="<%$ ConnectionStrings:usagelogConnectionString %>"
        SelectCommand="SELECT * FROM [Vendors] ORDER BY [F1]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource4" runat="server"
        ConnectionString="<%$ ConnectionStrings:usagelogConnectionString %>"
        SelectCommand="SELECT * FROM [Industry] ORDER BY [F1]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource5" runat="server"
        ConnectionString="<%$ ConnectionStrings:usagelogConnectionString %>"
        SelectCommand="SELECT * FROM [contenttype] ORDER BY [F1]">
    </asp:SqlDataSource>
    </form>
</body>
</html>

3 Answers, 1 is accepted

Sort by
0
Toshiyuki
Top achievements
Rank 1
answered on 24 Jan 2011, 03:57 AM

Hi,
I also posted this into technet forum & was advised to run SQL Server Profiler & found when the update command was executed, 'Null' was inserted into the column where I want to insert multiple choices in text as you see below. Is this a bug?

Regards,
Toshiyuki

one selected from combobox

exec sp_executesql N'UPDATE [OriginalReport] SET [F2] = @F2, [F3] = @F3, [F4] = @F4, [F5] = @F5, [F6] = @F6, [F7] = @F7, [F8] = @F8, [F9] = @F9, [F10] = @F10 WHERE [F1] = @F1',N'@F2 datetime,@F3 nvarchar(9),@F4 nvarchar(24),@F5 nvarchar(11),@F6 nvarchar(5),@F7 nvarchar(9),@F8 nvarchar(20),@F9 nvarchar(9),@F10 nvarchar(5),@F1 int',@F2='12 20 2006 12:00:00:000AM',@F3=N'NET-06-53',@F4=N'ReportTitle',@F5=N'EnglishName',@F6=N'JapaneseName',@F7=N'Forecasts',@F8=N'Healthcare Providers',@F9=N'Cisco Systems, Inc.',@F10=N'test4',@F1=843

more than two selected from combobox

exec sp_executesql N'UPDATE [OriginalReport] SET [F2] = @F2, [F3] = @F3, [F4] = @F4, [F5] = @F5, [F6] = @F6, [F7] = @F7, [F8] = @F8, [F9] = @F9, [F10] = @F10 WHERE [F1] = @F1',N'@F2 datetime,@F3 nvarchar(9),@F4 nvarchar(24),@F5 nvarchar(11),@F6 nvarchar(5),@F7 nvarchar(9),@F8 nvarchar(26),@F9 nvarchar(4000),@F10 nvarchar(5),@F1 int',@F2='12 20 2006 12:00:00:000AM',@F3=N'NET-06-53',@F4=N'ReportTitle',@F5=N'EnglishName',@F6=N'JapaneseName',@F7=N'Forecasts',@F8=N'Manufacturing (Technology)',@F9=NULL,@F10=N'test4',@F1=843

0
Toshiyuki
Top achievements
Rank 1
answered on 24 Jan 2011, 06:44 AM
I found a related post but couldn't figure out what it means.
http://www.telerik.com/community/forums/aspnet/combobox/radcombobox-allowcustomtext-custom-text-not-saving.aspx

Solution
This is so because SelectedValue returns empty string when you enter custom text in the ComboBox. In this case, you need to use the Text property. A check for an empty SelectedValue and getting the correct property will resolve this.

Can any of you tell me how I can apply this change on my source?


0
Marin
Telerik team
answered on 26 Jan 2011, 02:52 PM
Hi Toshiyuki,

Try binding the Text property of the combo box instead. The SelectedValue might not be initialized in this scenario:

<telerik:RadComboBox ID="F9RadComboBox" runat="server" AllowCustomText="True"
                                        AutoCompleteSeparator=";" DataSourceID="SqlDataSource2" DataTextField="F1"
                                        DataValueField="F1" Height="19px" MarkFirstMatch="True"
                                        Text='<%# Bind("F9") %>' Width="504px"  MaxHeight="500px" >
                                    </telerik:RadComboBox>

 

Best wishes,
Marin
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Toshiyuki
Top achievements
Rank 1
Answers by
Toshiyuki
Top achievements
Rank 1
Marin
Telerik team
Share this question
or