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

RadComboBox of OnItemsRequested null value will pop up error as shown in Appendix figure

1 Answer 45 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
ghd258 ghd258
Top achievements
Rank 1
ghd258 ghd258 asked on 21 Jan 2018, 07:01 AM

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProFlowDirectionEdit.aspx.cs" Inherits="Healthway.XA.Web.UI.Pages.FlowDirection.ProFlowDirectionEdit" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
          <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
        <div>
            <telerik:RadComboBox  ID="RadComboBoxProduct" runat="server" Height="200" Width="315" 
DropDownWidth="315"  Text="" HighlightTemplatedItems="true"
EnableLoadOnDemand="true" Filter="StartsWith" OnItemsRequested="rcbCustomer_ItemsRequested"
Skin="Office2010Silver">
<HeaderTemplate>
<table style="width: 275px" cellspacing="0" cellpadding="0">
<tr>
<td style="width: 175px;">
Product Name
</td>
<td style="width: 60px;">
Quantity
</td>
<td style="width: 40px;">
Price
</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table style="width: 275px" cellspacing="0" cellpadding="0">
<tr>
<td style="width: 175px;">
<%# DataBinder.Eval(Container, "Text")%>
</td>
<td style="width: 60px;">
<%# DataBinder.Eval(Container, "Attributes['CusCode']")%>
</td>
<td style="width: 40px;">
<%# DataBinder.Eval(Container, "Attributes['CusName']")%>
</td>
</tr>
</table>
</ItemTemplate>
</telerik:RadComboBox>
        </div>

    </form>
</body>
</html>

 

 protected void rcbCustomer_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
        {

            string sqlSelectCommand = "SELECT [CusCode], [CusName] from [Customer] WHERE [CusName] LIKE @text + '%' ORDER BY [CusName]";

            SqlDataAdapter adapter = new SqlDataAdapter(sqlSelectCommand,
                ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
            adapter.SelectCommand.Parameters.AddWithValue("@text", e.Text);
            DataTable dataTable = new DataTable();
            adapter.Fill(dataTable);

            foreach (DataRow dataRow in dataTable.Rows)
            {
                RadComboBoxItem item = new RadComboBoxItem();

                item.Text = (string)dataRow["CusName"];
                item.Value = dataRow["CusCode"].ToString();



                //RadComboBoxProduct.Items.Add(item);

                item.DataBind();
            }
        }

 

1 Answer, 1 is accepted

Sort by
0
ghd258 ghd258
Top achievements
Rank 1
answered on 21 Jan 2018, 07:06 AM
The 2016.1.225.40 version is OK, and the later version has this error
双语对照

Tags
General Discussions
Asked by
ghd258 ghd258
Top achievements
Rank 1
Answers by
ghd258 ghd258
Top achievements
Rank 1
Share this question
or