2013-02-20 32 views
-2

我期待更新由用戶給出的細節,如名稱,地址..等在表中,並顯示在gridview。創建一個gridview並用給定的細節更新表

,這樣我可以編輯在GridView /更新本身

string s = Session["something"].ToString(); 
      string str=string.Empty; 

     //bool bNextResult; 
     SqlConnection con = new SqlConnection("server=AMRNDHW1995\\DEV1;UID=POMS_ZOETIS_D_RO;[email protected]; database=POMS_Zoetis_D;"); 

     SqlCommand cmd = new SqlCommand("select amount from budget_detail where year='" + s + "'", con); 
     SqlDataReader dr; 
     con.Open(); 
     dr = cmd.ExecuteReader(); 
     SqlDataAdapter da = new SqlDataAdapter(cmd); 



     //DataSet ds =new DataSet(); 
     //da.Fill(ds); 


     //while (bNextResult == true) 
     //{ 

     while (dr.Read()) 
     { 

      str += dr.GetValue(0).ToString()    
       +"\n"; 
+1

請澄清你的問題。你想實現什麼? – 2013-02-20 10:02:50

回答

0
DataRow DR = dtTable.NewRow(); 
DR["Name"]=TxtName.Text; 
DR["Age"]=TxtAge.Text; 
DR["Place"]=TxtPlace.Text; 
dtTable.adtTable.Rows.Add(DR); 
dataGridView1.DataSource = dtTable;