麻烦各位老师有空的帮我看一下这串代码,谢谢。
这个功能是根据输入的地址查询SQL语句:
private static string FindByStartSQL = "select filightNo,startAddress,endAddress,startTime,economy,luxury from flight where startAddress='@startAddress'";
方法:
public static List<Models.flight> FindByStart(string startAddress)
{
List<Models.flight> list = new List<Models.flight>();
SqlParameter[] pars ={
new SqlParameter("@startAddress",SqlDbType.NVarChar)
};
pars[0].Value = startAddress;
DataSet ds = DBHelper.GetDataSet(FindByStartSQL, CommandType.Text, pars);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
// id, flightNo, startAddress, endAddress, startTime, economy, luxury
Models.flight m = new Models.flight();
m.flightNo = ds.Tables[0].Rows[i]["flightNo"].ToString();
m.startAddress = ds.Tables[0].Rows[i]["startAddress"].ToString();
m.endAddress = ds.Tables[0].Rows[i]["endAddress"].ToString();
m.startTime = ds.Tables[0].Rows[i]["startTime"].ToString();
m.economy = Int32.Parse(ds.Tables[0].Rows[i]["economy"].ToString());
m.luxury = Int32.Parse(ds.Tables[0].Rows[i]["luxury"].ToString());
list.Add(m);
}
return list;
}
BLL里边的方法:
public static List<Models.flight> FindByStart(string startAddress)
{
return DAL.flightService.FindByStart(startAddress);
}
页面按钮的代码:
if (TxtStart.Text!="")
{
if (!Page.IsPostBack)
{
GridView1.DataSource = BLL.flightManager.FindByStart(this.TxtStart.Text);
GridView1.DataBind();
}
}
gridview显示不出来 麻烦各位老师给我看一下该怎么做啊?我才学ASP不久。