vs2005中gridview的RowCommand事件
具体代码如下
protected
void
GridView1_RowCommand(
object
sender, GridViewCommandEventArgs e)
{
// e.CommandArgument获得命令行的索引
if (e.CommandName == " SetNotice " )
{
if ( ! demo.methods(Convert.ToInt32( this .GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value),
userid))
{
base .MessageBox( string .Empty, OpNotice.strErrMsg);
}
else
{
base .MessageBox( string .Empty, " 设置成功 " );
DataBinds();
}
}
}
{
// e.CommandArgument获得命令行的索引
if (e.CommandName == " SetNotice " )
{
if ( ! demo.methods(Convert.ToInt32( this .GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value),
userid))
{
base .MessageBox( string .Empty, OpNotice.strErrMsg);
}
else
{
base .MessageBox( string .Empty, " 设置成功 " );
DataBinds();
}
}
}
posted on 2006-05-30 13:10 随 想 阅读(611) 评论(1) 编辑 收藏 引用 网摘 所属分类: asp.net
评论
{
if (e.CommandName == "SetStatus")
{
string commstr = ((LinkButton)GridView1.Rows[Convert.ToInt32(e.CommandArgument)].Cells[3].Controls[0]).Text;
if (commstr == "设为私有") //change for field's [status]=1
{
if (!opProduct.Sys_SetStatus(Convert.ToInt32(GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value), 1))
{
MessageBox(string.Empty, opProduct.strErrMsg);
}
else
{
DataBinds();
}
}
else if (commstr == "设为公开")//change for field's [status]=0
{
if (!opProduct.Sys_SetStatus(Convert.ToInt32(GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value), 0))
{
MessageBox(string.Empty, opProduct.strErrMsg);
}
else
{
DataBinds();
}
}
}
if (e.CommandName == "SetCommend") //insert product commend
{
if (!opProductCommend.SysIsExist(Convert.ToInt32(GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value)))
{
MessageBox(string.Empty, opProductCommend.strErrMsg);
}
else
{
if (opProductCommend.dataView.Table.Rows.Count > 0)
{
MessageBox(string.Empty, "推荐已存在");
return;
}
}
if (!opProductCommend.SysInsert(Convert.ToInt32(GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value)))
{
MessageBox(string.Empty, opProductCommend.strErrMsg);
}
else
{
MessageBox(string.Empty, "推荐成功");
DataBinds();
}
}