日期:2014-05-18 浏览次数:20747 次
//鼠标移动改变行的颜色,自动编号 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { //其实就是给GridView加上鼠标划过的JS if (e.Row.RowType == DataControlRowType.DataRow) { //当鼠标停留时更改背景色 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#EBFBBA'"); //当鼠标移开时还原背景色 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c"); //单击/双击 事件 e.Row.Attributes["ondblclick"] = String.Format("javascript:dbl_click=true;window.open('check_xx.aspx?id={0}','mainFrame');", GridView1.DataKeys[e.Row.RowIndex].Value.ToString()); e.Row.Attributes["title"] = "双击打开详细页面"; e.Row.Attributes.Add("onclick", "clickevent(this.Panel1.Visible=true)"); //自动编号 if (e.Row.RowIndex != -1) { int idb = e.Row.RowIndex + 1; e.Row.Cells[0].Text = idb.ToString(); } //判断事由事项字符大于15个字后用...替代 if ((e.Row.Cells[3].Text).Length > 10) { e.Row.Cells[3].Text = (e.Row.Cells[3].Text).Substring(0, 10) + "…"; } if ((e.Row.Cells[4].Text).Length > 10) { e.Row.Cells[4].Text = (e.Row.Cells[4].Text).Substring(0, 10) + "…"; } } }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { this.Label2.Text = this.GridView1.SelectedValue.ToString(); this.Panel1.Visible = true; //string number=this.GridView1.Rows[1].Cells.ToString(); //this.Label3.Text = this.GridView1.Rows[1].Cells.ToString(); //接收订单号 string sql = "select * from A where id=" + this.Label2.Text; sms_conn.Open(); SqlDataAdapter da = new SqlDataAdapter(sql, sms_conn); DataSet ds = new DataSet(); da.Fill(ds, "A"); DataRowView rowview = ds.Tables["A"].DefaultView[0]; this.Label3.Text = rowview["number"].ToString(); string Sql2 = "select * from checksh where num="+ "'"+this.Label3.Text+"'"; SqlDataAdapter da2 = new SqlDataAdapter(Sql2, sms_conn); DataSet ds2 = new DataSet(); try { da2.Fill(ds2, "checksh"); GridView2.DataSource = ds2.Tables["checksh"].DefaultView; GridView2.DataBind(); } catch (Exception ex) {
Button btn = e.Row.FindControl("buttonid") as Button; if(btn!=null) { e.Row.Attributes.Add("onclick", "document.getElementById('btn.ClientID').click();"); }
MS官方的ASP.Net AJAX 1.0如何用,简单的联动