AutoComplete与RadioButtonList1配合使用遇到的问题,在线等
我用的是vs2008的AutoComplete控件,如果单独与TextBox控件使用,是没有问题的,代码如下:
public static string[] GetCompletionList(string prefixText, int count, string contextKey)
{
SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand cmd = new SqlCommand("SELECT cp_name FROM chanpin WHERE cp_name like '%" + prefixText + "%' ORDER BY cp_id DESC", cn);
cn.Open();
。
。
}
====================
但我想和RadioButtonList1配合使用,即代码如下:
public string[] GetCompletionList(string prefixText, int count, string contextKey)
{
string abc = "";
SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
if (RadioButtonList1.SelectedItem.Text == "公司")
{
abc = "select g_name from gscx where g_name like '%" + prefixText + "%' order by g_id desc";
}
else if (RadioButtonList1.SelectedItem.Text == "产品")
{
abc = "select cp_name from chanpin where cp_name like '%" + prefixText + "%' order by cp_id desc";
}
。
。。
}
以上代码没有反应,即得不出自动完成效果,也没有任何错误提示,望高手解答。
我用的是vs2008的AutoComplete控件,如果单独与TextBox控件使用,是没有问题的,代码如下:
public static string[] GetCompletionList(string prefixText, int count, string contextKey)
{
SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand cmd = new SqlCommand("SELECT cp_name FROM chanpin WHERE cp_name like '%" + prefixText + "%' ORDER BY cp_id DESC", cn);
cn.Open();
。
。
}
====================
但我想和RadioButtonList1配合使用,即代码如下:
public string[] GetCompletionList(string prefixText, int count, string contextKey)
{
string abc = "";
SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
if (RadioButtonList1.SelectedItem.Text == "公司")
{
abc = "select g_name from gscx where g_name like '%" + prefixText + "%' order by g_id desc";
}
else if (RadioButtonList1.SelectedItem.Text == "产品")
{
abc = "select cp_name from chanpin where cp_name like '%" + prefixText + "%' order by cp_id desc";
}
。
。。
}
以上代码没有反应,即得不出自动完成效果,也没有任何错误提示,望高手解答。
解决方案 »
- 有高手愿意教我ASP.NET的treeview控件怎么使用吗?
- asp.net2.0 中如何实现flash的按钮转页面事件
- 存储过程分页后,数据集更新的问题?主要是如何通过代码指定各行的状态为添加,修改,还是删除?
- 问个菜的datagrid的问题?
- 自定义服务器控件如何在页面任意位置输出内容。如在body标记中添加事件
- 请求写一个正确的用于ASP。NET AJAX1.0的JAVASCRIT脚本文件
- 如何设置下拉框中的值!急
- 求救,IE6.0上用Accept属性设置文件上传控件的上传文件类型无效?
- 不知道当前页的网址如何刷新当前页??
- 异常处理
- 做asp网站,用什么开发程序好?
- 怎么检查数据类型 .net
。
你改用selectedvalue,试下
RadioButtonList1.SelectedValue
和
public string[] GetCompletionList
的区别啊?
我用static ,RadioButtonList1就提示出错
这个方法,RadioButtonList1的值,怎么存,没搞懂。