本文介绍了想要根据所选的下拉列表值显示数据库中的数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我想根据选定的下拉值显示数据库中的数据。
我的代码:
.aspx.cs
protected void ddlDisplayName_SelectedIndexChanged( object sender,EventArgs e)
{
AdminActivityBL ObjAdminActivity = new AdminActivityBL();
ObjAdminActivity.GetDisplayNames_Details();
string SelectedValue = ddlDisplayName.SelectedItem.Value;
}
Bussines图层:
public DataSet GetDisplayNamesDetails()
{
AdminActivityDB objAdminActivityDB = new AdminActivityDB();
return objAdminActivityDB.GetDisplayNamesDetails();
}
数据访问层:
public DataSet GetDisplayNamesDetails()
{
try
{
Database objDB = new SqlDatabase(ConfigurationHelper.ConnectionString);
使用(DbCommand objCMD = objDB.GetStoredProcCommand(Constants.USP_GET_DISPLAYNAMES_DETAILS))
{
DataSet retDS = objDB.ExecuteDataSet(objCMD) ;
return retDS;
}
}
catch (例外情况)
{
// EventLog objLog = new EventLog();
// objLog.LogError(ex);
throw ex;
}
}
这是对的吗?
: - )
解决方案
Hi everyone,
I would like to display the data from database as per the selected value of drop down.
My code:
.aspx.cs
protected void ddlDisplayName_SelectedIndexChanged(object sender, EventArgs e) { AdminActivityBL ObjAdminActivity = new AdminActivityBL(); ObjAdminActivity.GetDisplayNames_Details(); string SelectedValue = ddlDisplayName.SelectedItem.Value; }
Bussines layer:
public DataSet GetDisplayNamesDetails() { AdminActivityDB objAdminActivityDB = new AdminActivityDB(); return objAdminActivityDB.GetDisplayNamesDetails(); }
Data access layer:
public DataSet GetDisplayNamesDetails() { try { Database objDB = new SqlDatabase(ConfigurationHelper.ConnectionString); using (DbCommand objCMD = objDB.GetStoredProcCommand(Constants.USP_GET_DISPLAYNAMES_DETAILS)) { DataSet retDS = objDB.ExecuteDataSet(objCMD); return retDS; } } catch (Exception ex) { //EventLog objLog = new EventLog(); //objLog.LogError(ex); throw ex; } }
Is this something right?
:-)
解决方案
这篇关于想要根据所选的下拉列表值显示数据库中的数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!