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

x
?
Solved

populate gridview with dropdown value ISSUE PLEASE HELP

Posted on 2012-04-09
5
Medium Priority
?
237 Views
Last Modified: 2012-04-12
I have a dropdown control that returns all the States.  When the state is selected I would like to show the results in a gridview control or datagrid.  Not sure which one would be the best.

When I tried to use the gridview control it took my value of GA and put it on two rows. I have attached a screenshot of this.  I think i am missing something simple here but not very fimiliar with VB.net and have been learning as I code for this huge project I am so behind on.
Any ideas?  thanks in advance!

Dim state As String = ddlStates.SelectedItem.Value
        lblCityError.Text = ""

        Dim ds As New DataSet()
        Dim dt As New DataTable()
        ds.Tables.Add()

        dt.Columns.Add(New System.Data.DataColumn("State", GetType([String])))

        gvState.DataSource = ddlStates.SelectedItem.Value
        gvState.DataBind()

Open in new window

Enter-Payor-State-OR-Zip-Code-fo.docx
0
Comment
Question by:codeJen
[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
  • 3
  • 2
5 Comments
 
LVL 17

Expert Comment

by:nepaluz
ID: 37838120
Not sure why you are declaring a dataset (neither the datatable but I have made use of it here)
Dim dt As New DataTable()
dt.Columns.Add(New System.Data.DataColumn("State", GetType([String])))
Dim dr As DataRow = dt.NewRow()
dr.ItemArray(ddlStates.SelectedItem.Value)
dt.Rows.Add(dr)
gvState.DataSource = dt

Open in new window

0
 

Author Comment

by:codeJen
ID: 37838206
Yea I'm a nub at this stuff and the company i work for expects us to learn on the fly without training.  I probably tried to many ways and have gotten confused over the course of it.  Anyways I am getting an error on
dr.ItemArray(ddlStates.SelectedItem.Value)

Says: property access must assign to the property or use its value?
0
 
LVL 17

Accepted Solution

by:
nepaluz earned 2000 total points
ID: 37838267
Applyt the ToString method,e.g
dr.ItemArray(ddlStates.SelectedItem.Value.ToString)

Open in new window

or do:
dr.Item(0) = ddlStates.SelectedItem.Value.ToString

Open in new window

0
 

Author Closing Comment

by:codeJen
ID: 37838300
I used dr.Item(0) = ddlStates.SelectedItem.Value.ToString and that did the trick!    Thank you soooooooo much!! You're a time saver! :)
0
 
LVL 17

Expert Comment

by:nepaluz
ID: 37838358
Bear in mind to select the correct zone when asking a question. If you'd put this in Visual Basic .NET, you would have received an answer quicker!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

721 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