Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Fill Gridview - Dropdowlist

Posted on 2006-07-22
3
Medium Priority
?
210 Views
Last Modified: 2008-02-01
How can I select the element from dropdowlist and display a record on Gridview?




Imports System.Data
Imports System.Data.SqlClient  


 Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click


        Dim StrConnection As String = "mystring"
        Dim Con As New SqlConnection(StrConnection)
        Dim StrCommand As String = "select *from logmein where ?????????????????????????? - "
        Dim Da As New SqlDataAdapter(StrCommand, Con)
        Dim table As New DataTable


        Da.Fill(table)


        GridView1.DataSource = table
        GridView1.DataBind()


   

    End Sub
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 17162969
Imports System.Data
Imports System.Data.SqlClient  


 Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click

        Dim userID As String = Me.DropDownList1.SelectedValue

        Dim StrConnection As String = "mystring"
        Dim Con As New SqlConnection(StrConnection)
        Dim StrCommand As String = String.Format("select * from logmein where userID =  '{0}' ", userID)
        Dim Da As New SqlDataAdapter(StrCommand, Con)
        Dim table As New DataTable

        Da.Fill(table)

        GridView1.DataSource = table
        GridView1.DataBind()

    End Sub

Bob
0
 

Author Comment

by:VBdotnet2005
ID: 17163436
I still new. Could you explain this a little bit? I haven't seen used before.

 Dim StrCommand As String = String.Format("select * from logmein where userID =  '{0}' ", userID)
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 17163590
If you look up String.Format, it is a shared member of the String class that takes a variable number of arguments {0}, {1}, ..., {n} and replaces them in the string.  It is a much cleaner way of building a formatted string, given certain inputs, versus using string concatenation (userID = '" & userID & "'").  Each of the arguments gets replaced in the string, so userID = 0.  

Another example:

  Dim test As String = String.Format("Item #1 = {0}, Item #2 = '{1}', Item #3 = {2}", item1, item2, item3)

Bob
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question