VB.NET method for dropdownlist binding.....................

Unknown | 6:41 AM |

Public Shared Sub combofill(ByVal cmm As SqlCommand, ByVal dropdown As DropDownList, ByVal valuefield As String, ByVal textfield As String)
        dropdown.Items.Clear()
        Dim dt As DataTable
        dt = DataConnect.GetInstance.GetDt(cmm)
        dt.TableName = "dt"
        Dim dr As DataRow
        dr = dt.NewRow()
        dr(valuefield) = 0
        dr(textfield) = "Select"
        dt.Rows.Add(dr)
        dt.AcceptChanges()

        Dim dw As New DataView
        dw = New DataView
        dw.Table = dt
        dw.Sort = valuefield & " asc"

        dropdown.DataSource = dw
        dropdown.DataTextField = textfield
        dropdown.DataValueField = valuefield
        dropdown.DataBind()

        dropdown.SelectedValue = 0
        dropdown.DataSource = dw
        dropdown.DataTextField = textfield
        dropdown.DataValueField = valuefield
        dropdown.DataBind()
        dropdown.SelectedValue = 0
    End Sub

Category:

About http://dotnetvisual.blogspot.in/:
DOT NET TO ASP.NET is a web application framework marketed by Microsoft that programmers can use to build dynamic web sites, web applications and web services. It is part of Microsoft's .NET platform and is the successor to Microsoft's Active Server Pages (ASP) technology. ASP.NET is built on the Common Language Runtime, allowing programmers to write ASP.NET code using any Microsoft .NET language. create an application very easily ....