cs中代码如下:谢谢了!拜托了!接分了!public class manager : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button mybtn;
protected System.Web.UI.WebControls.DropDownList list1;
protected System.Web.UI.WebControls.DataGrid mydg;
protected System.Web.UI.WebControls.Label mylabel;
protected System.Data.DataView objdv;
void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
BindData();
}
}
void BindData()
{
string strconn,strsql;
strconn=@"Provider=Microsoft.Jet.OleDb.4.0;"+
"Data Source="+Server.MapPath("computer.mdb");
strsql="select * from news";
DataSet objds=new DataSet();
OleDbConnection objconn=null;
OleDbDataAdapter objadapter=null;
objconn=new OleDbConnection(strconn);
objadapter=new OleDbDataAdapter(strsql,objconn);
objadapter.Fill(objds,"news");
//show
objdv=new DataView(objds.Tables["news"]);
mydg.DataSource=objdv;
mydg.DataBind();
}
protected void mydg_Changed(object sender, DataGridPageChangedEventArgs E)
{
this.mydg.CurrentPageIndex=E.NewPageIndex;
BindData();
}
protected void mydg_command(object sender,DataGridCommandEventArgs e)
{
if (e.CommandName == "delete")
{
///这里不知该怎么写呀,真的很是无奈了!
}
BindData(); }
{
protected System.Web.UI.WebControls.Button mybtn;
protected System.Web.UI.WebControls.DropDownList list1;
protected System.Web.UI.WebControls.DataGrid mydg;
protected System.Web.UI.WebControls.Label mylabel;
protected System.Data.DataView objdv;
void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
BindData();
}
}
void BindData()
{
string strconn,strsql;
strconn=@"Provider=Microsoft.Jet.OleDb.4.0;"+
"Data Source="+Server.MapPath("computer.mdb");
strsql="select * from news";
DataSet objds=new DataSet();
OleDbConnection objconn=null;
OleDbDataAdapter objadapter=null;
objconn=new OleDbConnection(strconn);
objadapter=new OleDbDataAdapter(strsql,objconn);
objadapter.Fill(objds,"news");
//show
objdv=new DataView(objds.Tables["news"]);
mydg.DataSource=objdv;
mydg.DataBind();
}
protected void mydg_Changed(object sender, DataGridPageChangedEventArgs E)
{
this.mydg.CurrentPageIndex=E.NewPageIndex;
BindData();
}
protected void mydg_command(object sender,DataGridCommandEventArgs e)
{
if (e.CommandName == "delete")
{
///这里不知该怎么写呀,真的很是无奈了!
}
BindData(); }
解决方案 »
- 怎么根据Reapter控件中的值判断某列是否显示 再问一次 不是一般的
- gridview 单击事件 触发另一个事件 --- 事件怎样才能连续引发?
- 在线等 ObjectList 问题
- aspx转成htm
- 请问我想向数据库中的有联系的表插入数据,最正规的方法是什么?
- listbox怎么取得所有选择了的项的值
- 求助:ASP.NET中在WEB.CONFIG中如何写连接SYBASE数据库的连接字符串?
- 向前面成功安装了三楼楼长OA的朋友求助
- 在javascript中如何使用session,请各位帮忙,非常感谢
- 提示确定信息。
- 那位高手能讲一下DataBind()的捆绑(在线等待)
- 怎样通过一个按钮增开一个窗口?
这点我真的不知该从哪下手?
能帮我写一下吗?不懂的,我再问???
我是勤学好问的了,大家不要见笑!
写在dataitemcommand里面查查csdn
其常规调用者是CompiledTemplateBuilder,也就是模板ITemplate的一个实现.
你如果不想用ASP.NET的标记来关联事件,必须写一个符合BuildTemplateMethod的方法。然后在方法内创建控件,关联事件处理方法,
然后再往参数Control里塞.
具体做法很麻烦.用标记写方便多了。...
我搞了两天了,一点门都弄不出来,拜托了!
谢谢具体解决方法了,具体到哪查也好了。
中,
页面代码分离,你指的是什么?你不用<ASP:DataGrid/>的写法了么?
////这里该怎么写呀??????
}
string DeleStr="Delete from communicate where id = @Id";
SqlCommand MySqlCmd = new SqlCommand(DeleStr, MyConn);
MySqlCmd.Parameters.Add(new SqlParameter("@Id", SqlDbType.NVarChar, 11));
MySqlCmd.Parameters["@Id"].Value = Grid1.DataKeys[(int)e.Item.ItemIndex];
MySqlCmd.Connection.Open();
MySqlCmd.ExecuteNonQuery();
Grid1.CurrentPageIndex=0;
MySqlCmd.Connection.Close();
BindGrid();
}
还得需要帮忙。呵呵,不好意思。
谁能帮忙写一下了,今晚结贴!