日期:2014-05-19  浏览次数:20397 次

大仙们速来拿分!
如何在datagrid绑定数据后   在最下面多出一行   添加行!!


录入数据后   点添加按钮添加入
数据库且后添加按钮text变为编辑/保存!
新生提问了

------解决方案--------------------
假设你的按钮ID为Button1
private void Button1_Click(object sender, System.EventArgs e)
{
string strSql= "你数据插入语句 ";
EexcuteSql(strSql);
this.Button1.Text= "编辑/保存 ";
}
private void ExecuteSql(string strSql)
{
try
{
string strconn = System.Configuration.ConfigurationSettings.AppSettings[ "DSN "];//从Web.config中读取
SqlConnection conn =new SqlConnection(strconn);
SqlCommand com = new SqlCommand(strSql,conn);
conn.Open();
com.ExecuteNonQuery();
conn.Close();
}
catch(Exception e)
{
Response.Write( " <script language = 'javascript '> alert( ' "+e.Message+ " '); </script> ") ;

}
}