2013-03-30 69 views
0

// LinkBut​​ton的定義aspx頁面該按鈕的OnClick工作得很好,在更新數據庫,但使用的LinkBut​​ton的problemis沒有效果

<asp:LinkButton ID="linkUpdate" runat="server" OnClick="linkUpdate_Click">Update </asp:LinkButton> 

// linkUpdate_Click - 得到執行我想要的動作時的LinkBut​​ton點擊

protected void linkUpdate_Click(object sender, EventArgs e) 
{ 

    string DeptName = txtName.Text; 
    string Profile = txtProfile.Text; 

    string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["connectionStringName"].ConnectionString; 
    using (SqlConnection connection = new SqlConnection(connectionString)) 
    { 
     string sql = "update Sectors set DeptName = '" + txtName.Text + "',Profile='" + txtProfile.Text + "' where DeptID =1"; 
     connection.Open(); 
     SqlCommand cmd = new SqlCommand(sql, connection); 
     cmd.ExecuteNonQuery(); 
     Response.Redirect("Architecture.aspx"); 
     connection.Close(); 
    } 


} 

回答

相關問題