2009-11-23 99 views
0

使用VB.Net如何在表中插入一個值?

是新的vb.net,現在用的datagridview

的DataGridView

ID Name ComboboxColumn 

001 Raja 
002 Ravi 
003 Suresh 
..., 

「保存」 - 按鈕

在一個DataGridView我在使用組合框列第三列

假設如果我從組合框中選擇值,那麼我按下保存按鈕意味着,Datagridview列值應保存在表中。

如果未在組合框中選擇該值,則ID和名稱不應保存在表中。

如何爲這種情況製作查詢或代碼?

需要vb.net代碼幫助

回答

1

循環通過GridView

for(int i=0; i<= GridView1.Rows.Count-1; i++) 
{ 
    string comboValue = ((DropdownList)GridView1.Rows[i].FindControl("Dropdownlist1")).SelectedValue; 
    if(comboValue == "Yes") 
    { 

     //Save to database. Alternatively, you can load it in your business entity object and loop through the object collection and save it to the database individually. 
    } 

} 
+0

上午使用VB.Net,如何更改您的代碼。 – Gopal 2009-11-23 13:48:36

+0

在線使用**許多** C#到VB.NET轉換器之一,例如http://www.developerfusion.com/tools/convert/csharp-to-vb/ – 2009-11-23 13:57:12

+0

這個問題似乎是關於winforms DataGridView而不是asp.net的GridView。 – 2009-11-23 14:10:47

相關問題