更新时间:2023-01-12 22:07:41
使用where where条件并获取数据
use where condition and fetch the data
select * from yourtable where yourcolumn = 'columnVal'
使用查询:
Select * from Table_name WHERE Column_Name = Your_Value
让我们说你的结果数据表有5行而你想要将Column1绑定到您的下拉列表。
您只需要将数值从数据绑定到下拉列表
这里我改变你的代码
Lets say your result datatable has 5 rows and you want to bind Column1 to your dropdown.
All you need to do is just bind your values from datatable to dropdownlist
Here Iam changing your code
DataTable dt1 = new DataTable();
SqlConnection con1 = new SqlConnection(str);
con1.Open();
string query1 = "select Lot_No from tblStockDetail where ItemID = '" + txtItemID.Text + "'";
SqlDataAdapter ad1 = new SqlDataAdapter(query1, con1);
ad1.Fill(dt1);
cboLotNo.DataSource = dt1;
cboLotNo.DataTextField = "Column_Name"; // Lot_No Text displayed for User
cboLotNo.DataValueField = "Column_Name"; // Associated Primary key for each item
cboLotNo.DataBind();
txtQty.Focus();