Home  >  Article  >  php教程  >  gridview命令用法

gridview命令用法

WBOY
WBOYOriginal
2016-06-06 20:01:181652browse

/// 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(), "", "<script>alert(/"图片删除成功!/");</script>");

            }

            else

            {

                Page.ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert(/"图片删除失败!/");</script>");

            }

        }

        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);

        }

 

    }

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn