c#中datagridview控件中的数据如何更新到数据库中
c#中datagridview控件设置了允许添加新行,添加后的数据如何更新到数据库中,最好给代码和说明,谢谢大神...
c#中datagridview控件设置了允许添加新行,添加后的数据如何更新到数据库中,最好给代码和说明,谢谢大神
展开
1个回答
展开全部
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
Bind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int id = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
FriendlyLink flink = FriendlyLinkManager.GetFriendlyLink(id);
flink.Title = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtTitle")).Text;
flink.Url = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtUrl")).Text;
FriendlyLinkManager.SaveFriendlyLink(flink);
string url = Request.Url.ToString();
Response.Redirect(url);
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
Bind();
}
{
GridView1.EditIndex = e.NewEditIndex;
Bind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int id = int.Parse(GridView1.DataKeys[e.RowIndex].Value.ToString());
FriendlyLink flink = FriendlyLinkManager.GetFriendlyLink(id);
flink.Title = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtTitle")).Text;
flink.Url = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtUrl")).Text;
FriendlyLinkManager.SaveFriendlyLink(flink);
string url = Request.Url.ToString();
Response.Redirect(url);
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
Bind();
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |