ninel
Active member
I have a datagrid on my web form that needs to contain a dropdown within each row.
Here is the code I have so far:
This works perfectly....The only thing is I need the first entry in every dropdownlist to be "-SELECT-"
How can I insert that string into every dropdown?
Thanks,
Ninel
Here is the code I have so far:
VB.NET:
HTML: Just the template column of datagrid:
<asp:TemplateColumn HeaderText="Network Access Group">
<ItemTemplate>
<asp:DropDownList id="ddlNetworkAccessGroup" DataSource="<%#BindState()%>" DataTextField="sDescription" DataValueField="imsNetworkAccessGroupId " runat="server" Font-Name="Tahoma" Font-Size ="x-small" />
</ItemTemplate>
</ asp:TemplateColumn>
Code Behind:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim bPopulateGrid As Boolean
Try
If Not Page.IsPostBack Then
If Request.Cookies.Count = 1 Then
Response.Redirect("login.aspx")
ElseIf Request.Cookies.Count >= 2 Then
BindState()
End If
End If
Catch ex As Exception
lblResult.Text = ex.Message
End Try
End Sub
Public Function BindState()
Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("connString"))
Dim myCommand As SqlCommand = New SqlCommand("uspGetNetworkAccessGroup", myConnection)
myCommand.CommandType = CommandType.StoredProcedure
myConnection.Open()
Return myCommand.ExecuteReader(CommandBehavior.CloseConnection)
End Function
This works perfectly....The only thing is I need the first entry in every dropdownlist to be "-SELECT-"
How can I insert that string into every dropdown?
Thanks,
Ninel