首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2012-01-02 
大仙们速来拿分!如何在datagrid绑定数据后在最下面多出一行添加行!!录入数据后点添加按钮添加入数据库且后

大仙们速来拿分!
如何在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> ") ;

}
}

热点排行