Solved

populate gridview with dropdown value ISSUE PLEASE HELP

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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Wordpress Security 29 73
Is sending authentication through SOAP secure? 3 33
Intranet Site for Medical Practice 7 51
IntelliJ and Eclipse Neon 2 installations 4 36
When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

749 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