Private Sub loadUnit(ByVal productUnit As String)
Dim unit() As String
Dim i = 0
Dim db2 As New Bcwebcheck.DBProxy_Bcweb_new
Dim dr2 As SqlClient.SqlDataReader = Nothing
unit = productUnit.Split("/", 1000, StringSplitOptions.RemoveEmptyEntries)
For Each Str As String In unit
db2.ClearParameters()
db2.AddParameter("@Code", Str)
db2.ExecCommand("sp_bcweb_Select_ProductUnit", dr2)
While dr2.Read
Dim btn As Button = New Button()
' btn.ID = "Button" + i.ToString()
btn.ID = (dr2.Item("UnitCode").ToString())
btn.Text = (dr2.Item("UnitName").ToString())
btn.Attributes.Add("runat", "server")
'btn.Attributes.Add("OnClick", "btn_Click")
AddHandler btn.Click, AddressOf btn_Click
Panel1.Controls.Add(btn)
i += 1
End While
dr2.Close()
Next
db2.CloseConnection()
End Sub
Private Sub btn_Click(ByVal sender As Object, ByVal e As EventArgs)
Label1.Text = String.Format("Button {0} was pressed.", CType(sender, Button).ID)
End Sub