访问 SQL 查询结果下拉列表中
本文关键字:下拉列表 结果 查询 SQL 访问 | 更新日期: 2023-09-27 17:57:21
如何访问从SQL查询返回的第二个值? 显然,我将返回的第一个值分配给我的下拉列表,但是我以后如何在我的runaquery方法中获取employeeid值? 以下是我想做的,但不确定如何获取该值,而不是第二次调用 sql 服务器并再次运行查询......
private void populate DropDownMainScreen()
{
this.ddlemployee.DataSource = DoThis();
this.ddlemployee.DataTextField = "employeename";
this.ddlemployee.DataValueField = "employeename";
this.ddlemployee.DataBind();
}
private void DoThis()
{
SqlQueryBuilder = new StringBuilder();
SqlQueryBuilder.Append = "Select employeeID, employeename from personell";
//Actually run the query here
}
private void runaquery()
{
string employeename = this.ddlemployee.SelectedItem.Value;
int campaignID = ;
Showmetheresults(RunSQLQuery, employeename, employeeID)
}
我会这样做:
private void populate DropDownMainScreen()
{
this.ddlemployee.DataSource = DoThis();
this.ddlemployee.DataTextField = "employeename";
this.ddlemployee.DataValueField = "employeeID";
this.ddlemployee.DataBind();
}
private void DoThis()
{
SqlQueryBuilder = new StringBuilder();
SqlQueryBuilder.Append = "Select employeeID, employeename from personell";
//Actually run the query here
}
private void runaquery()
{
string employeename = this.ddlemployee.SelectedItem.DataTextField;
string employeID = this.ddlemployee.SelectedItem.Value;
int campaignID = ;
Showmetheresults(RunSQLQuery, employeename, employeeID)
}