Gridview command usage

Source: Internet
Author: User
Summary value: summaryparamnamesenderparamparamnameeparamprotectedvoidgvZhTiList_RowDataBound (objectsender, GridViewRowEventArgse) {if (e. Row. RowTypeDataControlRowType. DataRow) {if (e. Row.

/// Summary // value assignment //// 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

///

/// Assign a value

///

///

///

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

}

}

}

///

/// Function implementation

///

///

///

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 (/"the image is deleted successfully! /"); Script");

}

Else

{

Page. ClientScript. RegisterStartupScript (Page. GetType (), "", "script" alert (/"image deletion failed! /"); 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 );

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.