62,073
社区成员
发帖
与我相关
我的任务
分享
public tb_NewsType GetModel(int N_TypeId)
{
StringBuilder strSql = new StringBuilder();
strSql.Append("select top 1 N_TypeId,N_TypeName,N_FTypeId from tb_NewsType ");
strSql.Append(" where N_TypeId=@N_TypeId ");
SqlParameter[] parameters = {
new SqlParameter("@N_TypeId", SqlDbType.Int,4)};
parameters[0].Value = N_TypeId;
tb_NewsType model = new tb_NewsType();
DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
if (ds.Tables[0].Rows.Count > 0)
{
if (ds.Tables[0].Rows[0]["N_TypeId"].ToString() != "")
{
model.N_TypeId = int.Parse(ds.Tables[0].Rows[0]["N_TypeId"].ToString());
}
model.N_TypeName = ds.Tables[0].Rows[0]["N_TypeName"].ToString();
if (ds.Tables[0].Rows[0]["N_FTypeId"].ToString() != "")
{
model.N_FTypeId = int.Parse(ds.Tables[0].Rows[0]["N_FTypeId"].ToString());
}
return model;
}
else
{
return null;
}
}
this.ddlNewsType.DataSource = ntb.GetModel(model.N_TypeId);
this.ddlNewsType.DataTextField = "N_TypeName";
this.ddlNewsType.DataValueField = "N_TypeId";
this.ddlNewsType.DataBind();