Solved

populate gridview with dropdown value ISSUE PLEASE HELP

Posted on 2012-04-09
5
236 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 500 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
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…
Starting up a Project

635 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