CommandName="ed" ImageUrl="../images/user.gif" />
CommandName="del" ImageUrl="../images/delete.gif" />
{
string cmdName = e.CommandName;
int cmdId = Convert.ToInt32(e.CommandArgument); button的CommandArgument绑定该项数据的ID 、CommandName随便绑定一个值在RowCommand方法中获取该名字 如果是该CommandName就执行什么 protected void gvPro_RowCommand(object sender, GridViewCommandEventArgs e)
{
string cmdName = e.CommandName;
int cmdId = Convert.ToInt32(e.CommandArgument);
if (cmdName == "ed")
{
string sql = "select * from [Type_info] where [id]=" + cmdId;
}
else if (cmdName == "del")
{
string sql = "select * from [Type_info] where [id]=" + cmdId;
}
}
前台页面源代码里 在button按钮属性里加入 CommandName=" getvalue" 后台代码加入 protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)事件 if (e.CommandName == "getvalue"){ 1你这里只能获取datalist当前选择的第几列来根据这个查询数据库相应的第几条数据。2这里写链接数据库查询语句3绑定控件}
是什么数据库呢?