我正在使用telerik Radcombobox。我正在使用radcombobox itemsrequestd事件处理程序。
Private Sub cbocompanyname_ItemsRequested(sender As Object, e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles cbocompanyname.ItemsRequested
Dim combo As RadComboBox = DirectCast(sender, RadComboBox)
If e.Text <> "" Then
objdbconn.OpenConn()
Dim sql As String = "Select distinct company_gid, company_name from company_details WHERE company_name LIKE '%" + e.Text + "%'"
Dim dt As New DataTable()
dt = objdbconn.GetDatatable(sql)
objdbconn.CloseConn()
For Each row As DataRow In dt.Rows
Dim item As New RadComboBoxItem(row("company_name").ToString())
combo.Items.Add(item)
Next
End If
End Sub
这是我的Telerik RadCombobox设计:
<telerik:RadComboBox ID="cbocompanyname" runat="server" Width="75%" MaxLength="256" ShowToggleImage="false" Skin="WebBlue"
EmptyMessage="Select Company Name/Individual Name" ItemsPerRequest="50" AllowCustomText="true" EnableLoadOnDemand="true" ZIndex="100000">
</telerik:RadComboBox>
我在这里检查公司名称是否已经存在。
msSQL = "Select company_gid from company_details where company_name = '" & Replace(Trim(cbocompanyname.Text), "'", "'") & "'"
objdatatable = objdbconn.GetDatatable(msSQL)
If objdatatable.Rows.Count > 0 Then
objdbconn.CloseConn()
lblErrMsg.Text = "Company name already exists"
Exit Sub
End If
这是编辑页面。所以现在我想知道如何检查并添加公司名称。