Last post May 02, 2008 11:39 AM by MikeB55
Apr 27, 2008 09:17 PM|MikeB55|LINK
Hello everyone. Can somebody please translate this for me from C to VB? I'm have a gridview that displays a checkboxlist and there is also a new column with a textbox in it. When an item is checked in the checkboxlist, i want to grab the ID of the item
and the text from the checkbox. Picture a gridview that displays the title of books, the option to choose which book you want to purchase, one or many books, and the text box that allows you to enter a quantity of books. Thank you in advance.
for(int iCount=0 ; iCount < GridView.Rows.Count ; iCount++)
if(GridView.Rows[iCount].RowType == DataControlRowType.DataRow)
CheckBox cb = (CheckBox)GridView.Rows[iCount].Cells.FindControl("MyCheckBoxID");
TextBox tb = (TextBox)GridView.Rows[iCount].Cells.FindControl("TextBox1");
String s = tb.Text;
Apr 27, 2008 09:34 PM|jimmy q|LINK
For i as Integer = 0 to GridView.Rows.Count Step 1
If GridView.Rows(i).RowType = DataControlRowType.DataRow Then
dim cb As CheckBox = CType(GridView.Rows(i).Cells(1).FindControl("MyCheckBoxID"), CheckBox)
If cb.Checked Then
dim tb As TextBox = CType(GridView.Rows(i).Cells(2).FindControl("TextBox1"), TextBox)
dim s As String = tb.Text
However be weary that the code you posted is not complete and looks like there are scoping issues
Apr 28, 2008 02:32 AM|smoothmovz|LINK
you could use this site to translate c# to vb.
Apr 28, 2008 04:34 AM|harminder singh|LINK
Here's your VB.NET code, ready to go!
above url is very good. i have converted ur code from above url
May 02, 2008 11:39 AM|MikeB55|LINK
Thank you for your help. This worked.