当前位置: 代码迷 >> ASP.NET >> 大仙们速来拿分!解决方案
  详细解决方案

大仙们速来拿分!解决方案

热度:745   发布时间:2013-02-26 00:00:00.0
大仙们速来拿分!
如何在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> ") ;

}
}
  相关解决方案