如何使下拉列表与众不同? [英] How do I make a dropdown list distinct?

查看:60
本文介绍了如何使下拉列表与众不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我每次更改所选索引时都会重复编号



我尝试过的事情:



使用(SqlConnection con = new SqlConnection(conString))

{

using(SqlDataAdapter sda = new SqlDataAdapter())

{

cmd.Connection = con;

con.Open();

ddl.DataSource = cmd.ExecuteReader();

ddl.DataTextField = text;

ddl.DataValueField = value;

ddl.DataBind();

con.Close();

}

}

sqlStr.AppendLine(SELECT LoanTerm,LoanRate来自TDLoanRate);

sqlStr.AppendLine(LoanEffectFrom和LoanMaturity之间的GETDATE();

I will have repeat numbers everytime i change selected index

What I have tried:

using (SqlConnection con = new SqlConnection(conString))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
con.Open();
ddl.DataSource = cmd.ExecuteReader();
ddl.DataTextField = text;
ddl.DataValueField = value;
ddl.DataBind();
con.Close();
}
}
sqlStr.AppendLine("SELECT LoanTerm, LoanRate From TDLoanRate ");
sqlStr.AppendLine("where GETDATE() between LoanEffectFrom and LoanMaturity");

推荐答案

你的问题标题本身就有答案,如果你想选择e DISTINCT内容,使用SQL查询:

Your question title has the answer in itself, if you wanted to select the DISTINCT content, use the SQL query:
SELECT DISTINCT LoanTerm, LoanRate From...



这将返回不同的记录,有关详情,请参阅如何使用它,请阅读: ALL,DISTINCT,DISTINCTROW,TOP Predicates (Microsoft Access SQL)  [Access 2007 Developer Reference] [ ^ ]。



其次,第二次读你的问题,


This would return distinct records, for more on how to use this, please read this: ALL, DISTINCT, DISTINCTROW, TOP Predicates (Microsoft Access SQL) [Access 2007 Developer Reference][^].

Secondly, reading your question second time,

引用:

我会重复一遍我每次更改所选索引的数字

I will have repeat numbers everytime i change selected index

让我觉得问题可能是你在下拉列表中有多个记录。为此,我只需清除下拉列表中的前一项,然后在下拉列表中加载新列表。您可以尝试清除数据源并重新设置,或更改 ItemsSource 值以重新设置它。

Makes me think that maybe the problem is that you are having multiple records in the dropdown itself. For that, I simply clear the previous items in the dropdown and load the new list in the dropdown. You can try clearing the data source and set it again, or change the ItemsSource value to set it again.


这篇关于如何使下拉列表与众不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆