GridView“GridView1”激发了未处理的事件“RowDeleting”,点击编辑也是这样
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class NewsList2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Binder();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Request["TextBok1"] == "" || Request["TextBox2"] == "" || Request["TextBox3"] == "" || Request["TextBox4"] == "")
{
Button1.Attributes.Add("onclick", "alert('所有项均为必填');");
return;
}
DataClasses2DataContext data = new DataClasses2DataContext();
NewsInfo Info = new NewsInfo();
Info.新闻编号 = Convert.ToInt32(TextBok1.Text.Trim());
Info.新闻主题 = TextBox2.Text.Trim();
Info.发布日期 = TextBox3.Text.Trim();
Info.新闻内容 = TextBox4.Text.Trim();
data.NewsInfo.InsertOnSubmit(Info);
data.SubmitChanges();
Binder();
}
private void Binder()
{
this.GridView1.DataSourceID = null;
DataClasses2DataContext data = new DataClasses2DataContext();
var News = from NewsInfo in data.NewsInfo
select NewsInfo;
GridView1.DataSource = News;
GridView1.DataBind();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}这是我的代码,效果图如下
,为啥我点击编辑和删除就是不行了啊,能发布,但是发布了编辑和删除都错
GridView
------解决方案--------------------你的编辑与删除 可以有很多种做法 因为你现在的编辑与删除 还没有定义方法呢