private void Toadd_Click(object sender, System.EventArgs e)//增加代码
{
string type=o_type.Text;
int isout=is_out.SelectedIndex;
Sql sql=new Sql();
DataTable dt=new DataTable();
string sqlstr="select o_type from t_type where o_type='"+type+"' and is_out='"+isout+"'";
dt=sql.QueryT(sqlstr);
Response.Write(dt.Rows.Count.ToString());
if (dt.Rows.Count!=0)
{
warn.Text="<script>alert('该类型名已存在,请重新输入!')</script>";
}
else
{
sqlstr="insert into t_type (o_type,is_out) values('"+type+"','"+isout+"')";
try
{
sql.Execute(sqlstr);
}
catch
{
Response.Write(sqlstr);
Response.End();
}
Response.Write("<script>top.window.close();dialogArguments.win.location.href='toto.aspx';</script>");
}
}
//绑定代码
Sql sql=new Sql();//自定义类
DataTable dt=new DataTable();
string sqlstr="select o_type from t_type where is_out='"+is_out+"'";
                dt=sql.QueryT(sqlstr);//关键是在此处,每次添加后,再打开此页面,检测DT的值都是添加前的,困惑
ArrayList btt=new ArrayList();
foreach(DataRow myrow in dt.Rows)
{
btt.Add(myrow["o_type"]);
}
o_type.DataSource=btt;
o_type.DataBind();