Monday, August 25, 2008

Gridview Row DataBound and Row Command

PageIndexChanged
Occurs when one of the pager buttons is clicked, but after the GridView control handles the paging operation.
PageIndexChanging
Occurs when one of the pager buttons is clicked, but before the GridView control handles the paging operation.
PreRender
Occurs after the Control object is loaded but prior to rendering. (Inherited from Control.)
RowCancelingEdit
Occurs when the Cancel button of a row in edit mode is clicked, but before the row exits edit mode.
RowCommand
Occurs when a button is clicked in a GridView control.
RowCreated
Occurs when a row is created in a GridView control.
RowDataBound
Occurs when a data row is bound to data in a GridView control.
RowDeleted
Occurs when a row's Delete button is clicked, but after the GridView control deletes the row.
RowDeleting
Occurs when a row's Delete button is clicked, but before the GridView control deletes the row.
RowEditing
Occurs when a row's Edit button is clicked, but before the GridView control enters edit mode.
RowUpdated
Occurs when a row's Update button is clicked, but after the GridView control updates the row.
RowUpdating
Occurs when a row's Update button is clicked, but before the GridView control updates the row.
SelectedIndexChanged
Occurs when a row's Select button is clicked, but after the GridView control handles the select operation.
SelectedIndexChanging
Occurs when a row's Select button is clicked, but before the GridView control handles the select operation.
Sorted
Occurs when the hyperlink to sort a column is clicked, but after the GridView control handles the sort operation.
Sorting
Occurs when the hyperlink to sort a column is clicked, but before the GridView control handles the sort operation.
Unload
Occurs when the server control is unloaded from memory. (Inherited from Control.)



protected void gvWebSite_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) {
LinkButton btnButt = (LinkButton)e.Row.Cells[1].FindControl("btnDelete");
btnButt.CommandArgument = e.Row.RowIndex.ToString();
}
if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton l = (LinkButton)e.Row.FindControl("btnDelete"); l.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete " + DataBinder.Eval(e.Row.DataItem, "websitename") + " and all its contents?')");
} }



protected void gvWebSite_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Delete")) { int rowNumber = Convert.ToInt32(e.CommandArgument); string SiteName = ((Label)gvWebSite.Rows[rowNumber].FindControl("lblSiteName")).Text; string path = ((Label)gvWebSite.Rows[rowNumber].FindControl("lblAdsPath")).Text;
CurrentContext context = (CurrentContext)Session["CurrentContext"]; CurrentUser cuser = (CurrentUser)Session["CurrentUser"]; string PreferredDC = ConfigurationManager.AppSettings["PreferredDC"].ToString(); Microsoft.Provisioning.MPSWSProxy.WindowsBasedHosting.WindowsBasedHosting wbh = new Microsoft.Provisioning.MPSWSProxy.WindowsBasedHosting.WindowsBasedHosting(); wbh.Credentials = new NetworkCredential(cuser.SamAccountName, cuser.Password, cuser.Domain);
string mpsResponse = wbh.DeleteCustomerWebSite(Utilities.RemoveDCFromLdap(PreferredDC, path), SiteName, string.Empty, PreferredDC, string.Empty, true); Retrieve(); }
}



In Design Mode::

'> '>