111,126
社区成员
发帖
与我相关
我的任务
分享<asp:TextBox ID="TextBox10" runat="server" Width="0px" BorderWidth="0px"
Height="0px" BackColor="#EFF7FF"></asp:TextBox>
<asp:Button ID="Button2" runat="server" onclick="Button2_Click"
BorderWidth="0px" Height="0px" Width="0px" />
function ClickEvent1(r1,r3)
{
document.getElementById("<%= TextBox10.ClientID %>").value = r1;
document.getElementById("<%= Button2.ClientID %>").click();
}protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onmouseover", " c =this.style.backgroundColor; this.style.backgroundColor='#96C2F1'");
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor = c");
e.Row.Attributes["style"] = "cursor:hand";
e.Row.Attributes.Add("OnClick", "ClickEvent1('" + e.Row.Cells[0].Text + "','" + e.Row.Cells[2].Text + "')");
}
}
protected void Button2_Click(object sender, EventArgs e)
{
SqlConnection sqlcon = new SqlConnection();
sqlcon.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DB_CON"].ConnectionString;
sqlcon.Open();
SqlCommand sqlcom = new SqlCommand();
sqlcom.Connection = sqlcon;
sqlcom.CommandText = "select * from weather where ID = '" + TextBox10.Text + "' and Timestamp = '" + TextBox12.Text + "'";
sqlcom.CommandType = CommandType.Text;
SqlDataAdapter sqlda = new SqlDataAdapter(sqlcom);
ds = new DataSet();
sqlda.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
TextBox1.Text = ds.Tables[0].Rows[0][0].ToString();
TextBox2.Text = ds.Tables[0].Rows[0][8].ToString();
TextBox3.Text = ds.Tables[0].Rows[0][9].ToString();
TextBox4.Text = ds.Tables[0].Rows[0][10].ToString();
TextBox5.Text = ds.Tables[0].Rows[0][3].ToString();
TextBox6.Text = ds.Tables[0].Rows[0][4].ToString();
TextBox7.Text = ds.Tables[0].Rows[0][11].ToString();
TextBox8.Text = ds.Tables[0].Rows[0][12].ToString();
TextBox9.Text = ds.Tables[0].Rows[0][13].ToString();
}
}