Home > php教程 > php手册 > body text

gridview命令用法

WBOY
Release: 2016-06-06 20:01:18
Original
1659 people have browsed it

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

        }

 

    }

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!