Gridview problems

B

Backwards

Hi all,

Take this to be a very simple question. I have done a little dotnet
forms programing and now trying to create a custom internal website to
dispaly ever changing data but i seem to be having a problem adding a
gridview on.

here is the code i have but the gridview doesnt even show on the page
at all let alone the data.


Protected Sub Btn_details_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Btn_details.Click
Me.Image1.Visible = True
Me.Label1.Visible = True

Dim sqlhost As New
SqlClient.SqlConnection("Server=es70001;Database=host;trusted_connection=yes;")
sqlhost.Open()

Dim cmdhost As New SqlClient.SqlCommand
cmdhost.CommandText = "Select S2KStoreNbr, ServerName,
HostServerName, SQLVersion, SMS_IP, StoreLine_IP from
tbProdDelActStore where servername = '" + Me.DropDownList1.Text + "'"
cmdhost.CommandType = CommandType.Text
cmdhost.Connection = sqlhost
cmdhost.ExecuteNonQuery()

Dim ds As New DataSet
Dim da As New SqlDataAdapter(cmdhost)
da.Fill(ds, "Output")
GridView1.DataSource = ds
GridView1.DataMember = "Output"
GridView1.Visible = True
sqlhost.Close()
Me.Image1.Visible = False
Me.Label1.Visible = False
End Sub
 
D

David R. Longnecker

After your GridView1.DataSource, try adding:

GridView1.DataBind()

That will bind the data to the GridView. The reason that your GridView doesn't
show up is because, by default, an empty grid isn't displayed.

HTH.

-dl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top