有没有一个view去控制另外一个view上控件增删的例子
1个回答
展开全部
GridView中没有增加数据的事件
删除事件
protected void gvwCourse_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
Guid m_guidID = new Guid(gvwCourse.DataKeys[e.RowIndex].Value.ToString());
gvwCourseDataBind();//记得绑定
}
修改事件(比较多麻烦点)
protected void gvwCourse_RowEditing(object sender, GridViewEditEventArgs e)
{
gvwCourse.EditIndex = e.NewEditIndex;
gvwCourseDataBind();
}
protected void gvwCourse_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
Guid m_guid = new Guid(gvwCourse.DataKeys[e.RowIndex].Value.ToString());
string m_strName = ((TextBox)gvwCourse.Rows[e.RowIndex].FindControl("txtTitle")).Text.Trim();
HttpPostedFile m_postFile = ((HtmlInputFile)gvwCourse.Rows[e.RowIndex].FindControl("fileUpdate")).PostedFile;
if (m_postFile.FileName.Length != 0 && m_postFile.ContentLength != 0)
{
AddOnlineCourse(m_postFile, m_strName);
gvwCourse.EditIndex = -1;
gvwCourseDataBind();
}
gvwCourse.EditIndex = -1;
gvwCourseDataBind();
}
取消修改
protected void gvwCourse_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvwCourse.EditIndex = -1;
gvwCourseDataBind();
}
===========================================
当我用不同sql填充之后就不能用普通的事件来写
===========================================
可以的..或者你可以尝试下用gridview的RowDataBound和DataBound事件中处理你
删除事件
protected void gvwCourse_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
Guid m_guidID = new Guid(gvwCourse.DataKeys[e.RowIndex].Value.ToString());
gvwCourseDataBind();//记得绑定
}
修改事件(比较多麻烦点)
protected void gvwCourse_RowEditing(object sender, GridViewEditEventArgs e)
{
gvwCourse.EditIndex = e.NewEditIndex;
gvwCourseDataBind();
}
protected void gvwCourse_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
Guid m_guid = new Guid(gvwCourse.DataKeys[e.RowIndex].Value.ToString());
string m_strName = ((TextBox)gvwCourse.Rows[e.RowIndex].FindControl("txtTitle")).Text.Trim();
HttpPostedFile m_postFile = ((HtmlInputFile)gvwCourse.Rows[e.RowIndex].FindControl("fileUpdate")).PostedFile;
if (m_postFile.FileName.Length != 0 && m_postFile.ContentLength != 0)
{
AddOnlineCourse(m_postFile, m_strName);
gvwCourse.EditIndex = -1;
gvwCourseDataBind();
}
gvwCourse.EditIndex = -1;
gvwCourseDataBind();
}
取消修改
protected void gvwCourse_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
gvwCourse.EditIndex = -1;
gvwCourseDataBind();
}
===========================================
当我用不同sql填充之后就不能用普通的事件来写
===========================================
可以的..或者你可以尝试下用gridview的RowDataBound和DataBound事件中处理你
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询