欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

gridview命令用法

程序员文章站 2022-05-04 08:27:51
...

/// summary /// 赋值 /// /summary /// param name="sender"/param /// param name="e"/param protected void gvZhTiList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.RowState

///

/// 赋值

///

///

///

protected void gvZhTiList_RowDataBound(object sender, GridViewRowEventArgs e)

{

if (e.Row.RowType == DataControlRowType.DataRow)

{

if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)

{

LinkButton lnkbtnpicdel = new LinkButton();

lnkbtnpicdel = (LinkButton)e.Row.Cells[gvZhTiList.Columns.Count - 1].FindControl("lnkbtndelpic");

lnkbtnpicdel.CommandArgument = e.Row.RowIndex.ToString();

LinkButton lnkbtnisusers = new LinkButton();

lnkbtnisusers = (LinkButton)e.Row.Cells[gvZhTiList.Columns.Count - 2].FindControl("lnkbtnusers");

lnkbtnisusers.CommandArgument = e.Row.RowIndex.ToString();

}

}

}

///

/// 功能实现

///

///

///

protected void gvZhTiList_RowCommand(object sender, GridViewCommandEventArgs e)

{

if (e.CommandName == "delpic")

{

string strsqldel = "delete flash_upload where picid=" + gvZhTiList.DataKeys[Convert.ToInt32(e.CommandArgument.ToString())].Value;

int nums = SqlConnections.UpdateOrDelete(strsqldel);

if (nums > 0)

{

Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "");

}

else

{

Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "");

}

}

if (e.CommandName == "isusers")

{

string strsqlisusers = "update flash_upload set isenjoin=case isenjoin when 1 then 0 else 1 end where picid=" + gvZhTiList.DataKeys[Convert.ToInt32(e.CommandArgument.ToString())].Value;

SqlConnections.UpdateOrDelete(strsqlisusers);

}

}