# Code generated by region Web Form Designer
Override protected void OnInit (EventArgs e)
{
//
// CODEGEN: This call is required by the ASP. NET Web form designer.
//
InitializeComponent ();
Base. OnInit (e );
}
/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void InitializeComponent ()
{
This. Maid + = new System. Web. UI. WebControls. Maid pageindexchanged );
This. DataGrid1.SortCommand + = new System. Web. UI. WebControls. DataGridSortCommandEventHandler (this. DataGrid1_SortCommand );
This. Maid + = new System. Web. UI. WebControls. Maid (this. Maid deletecommand );
This. Maid + = new System. Web. UI. WebControls. Maid (this. Maid editcommand );
This. Maid + = new System. Web. UI. WebControls. Fig cancelcommand );
This. Maid + = new System. Web. UI. WebControls. Maid (this. Maid updatecommand );
}
# Endregion
Private void DataGrid1_DeleteCommand (object source, System. Web. UI. WebControls. DataGridCommandEventArgs e)
{
If (maid. Count = 1)
{
If (maid! = 0)
{
DataGrid1.CurrentPageIndex = maid-1;
}
}
Us. Userid = int. Parse (e. Item. Cells [0]. Text );
Us. users_del ();
Bind ();
}
Private void DataGrid1_SortCommand (object source, System. Web. UI. WebControls. DataGridSortCommandEventArgs e)
{
String str = e. SortExpression;
If (ViewState ["sort"]. ToString () = str + "desc ")
{
ViewState ["sort"] = str + "asc ";
}
Else
{
ViewState ["sort"] = str + "desc ";
}
Bind ();
}
Protected void button#click (object sender, System. EventArgs e)
{
String str = TextBox1.Text;
ViewState ["chazao"] = "useradmin like '%" + str + "% '";
Bind ();
}
Private void DataGrid1_PageIndexChanged (object source, System. Web. UI. WebControls. DataGridPageChangedEventArgs e)
{
DataGrid1.CurrentPageIndex = e. NewPageIndex;
Bind ();
}
Protected void DataGrid1_EditCommand (object source, DataGridCommandEventArgs e)
{
DataSet ds = us. users_sel ();
DataView dv = ds. Tables [0]. DefaultView;
DataGrid1.EditItemIndex = e. Item. ItemIndex;
DataGrid1.DataSource = dv;
DataGrid1.DataBind ();
}
Protected void maid cancelcommand (object source, maid e)
{
DataSet ds = us. users_sel ();
DataView dv = ds. Tables [0]. DefaultView;
DataGrid1.EditItemIndex =-1;
DataGrid1.DataSource = dv;
DataGrid1.DataBind ();
}
Protected void DataGrid1_UpdateCommand (object source, DataGridCommandEventArgs e)
{
String useradmin = (TextBox) e. Item. Cells [1]. Controls [0]). Text;
String username = (TextBox) e. Item. Cells [2]. Controls [0]). Text;
String email = (TextBox) e. Item. Cells [3]. Controls [0]). Text;
SqlConnection connUpdate = new SqlConnection (ConfigurationManager. receivettings ["connstr"]);
ConnUpdate. Open ();
String SQL _edit = "UPDATE users" + "SET useradmin = '" + useradmin + "'," + "username = '" + username + "', "+" useremail = '"+ email +" 'where userid = "+ e. item. cells [0]. text;
SqlCommand sqlCommandUpdate = new SqlCommand (SQL _edit, connUpdate );
SqlCommandUpdate. ExecuteNonQuery ();
ConnUpdate. Close ();
DataSet ds = us. users_sel ();
DataView dv = ds. Tables [0]. DefaultView;
DataGrid1.EditItemIndex =-1;
DataGrid1.DataSource = dv;
DataGrid1.DataBind ();
}
From snail bait