asp.net

来源:互联网 发布:知行理工app官方 编辑:程序博客网 时间:2024/05/21 06:39

int a = 1; int b = 1;
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            for (int j = 0; j < GridView1.Columns.Count; j++)
            {
                GridView1.Rows[i].Cells[j].Attributes.Add("onclick", "alert('"+a+" 行"+b+"列')");   
                b++;
                if (b >= GridView1.Columns.Count+1)
                { b = 1; }
            }
            a++;

protected void gvdegreetype_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='GhostWhite'");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'");
        }

 事务
 SqlTransaction str = con.BeginTransaction();
        cmd.Transaction = str;
        cmd.ExecuteNonQuery();
        str.Commit();

排序


ds.Tables[0].DefaultView.Sort = "id desc";
        GridView1.DataSource = ds.Tables[0].DefaultView;

//在服务器端添加删除确认
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
   {12
      if (e.Row.RowType == DataControlRowType.DataRow)
   {
   LinkButton btnDelete = (LinkButton)e.Row.FindControl("LinkButton1");
   btnDelete.Attributes.Add("onclick", "javascript:return " +"confirm('Are you sure you want to delete this record " +DataBinder.Eval(e.Row.DataItem, "编号") + "')");

 

    e.Row.Cells[8].Attributes.Add("onclick", "return confirm('删除此条记录?');");

 e.Item.Cells[i].Attributes.Add("Width", "80px")

 

 protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
    {
      
      if (ViewState["order"] == null)
        { ViewState["order"] = "asc"; }
        else
        {
            if (ViewState["order"].ToString() == "asc")
            {
                ViewState["order"] = "desc";
            }
            else
            { ViewState["order"] = "asc"; }
        }
        con = new SqlConnection(conn);
        string sel = "select * from flower";
        SqlDataAdapter sda = new SqlDataAdapter(sel, con);
        con.Open();
        DataSet ds = new DataSet();
        sda.Fill(ds);
   
        ds.Tables[0].DefaultView.Sort = e.SortExpression  +" "+ ViewState["order"].ToString();
   
        Session["aa"] = e.SortExpression + " " + ViewState["order"].ToString();
        GridView1.DataSource = ds.Tables[0].DefaultView;
        GridView1.DataBind();
        con.Close();
      
    }

 

e.Row.Attributes.Add("style", "background-color:Red;");

  bt.Command = new CommandEventHandler(this.btclick);
public void bt_click(object sender, CommandEventArgs  e)

 

 bt.Command = new EventHandler(this.btclick);
public void bt_click(object sender, EventArgs  e)

 

 

 sql返回
cmd.Parameters.Add("@aaa", SqlDbType.Int);
        cmd.Parameters["@aaa"].Direction = ParameterDirection.Output;

declare @aaa int
set @aaa=10
return @aaa
 cmd.Parameters.Add("@aaa", SqlDbType.Int);
        cmd.Parameters["@aaa"].Direction = ParameterDirection.ReturnValue;

 

  string aa = "aaa,aa|aa,aaaa,aa|aa,a,a,a,";
 string[] a = aa.Split(',','|');
      //foreach(string s in a)
        for (int i=0;i<a.Length;i++)
        { Response.Write(a[i]);

页面刷新

<meta   http-equiv="refresh"   content="20">  

 <meta   http-equiv="refresh"   content="20;url=http://kingsnet.126.com">