Solved

Displaying and Passing values from a dataadapter

Posted on 2006-11-27
3
206 Views
Last Modified: 2010-04-23
I'm hoping this is an easy one but I'm just overlooking something simple.


I have a data adapter a that pulls to values from the database.    One is a complete name of a document the other is a reference number.  I'm displaying the document name in a drop down for the users to select - it works fine, but when they select it, I want to pass the associated reference number  instead of the documents name.

code:

'sqlGetIMGDocsAdapter
        '
        Me.sqlGetIMGDocsAdapter.SelectCommand = Me.SqlSelectCommand41
        Me.sqlGetIMGDocsAdapter.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "sp_GetIMGDocs", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("IMGDOC_Code", "IMGDOC_Code"), New System.Data.Common.DataColumnMapping("DOC_Name", "DOC_Name")})})
        '
        'SqlSelectCommand41
        '
        Me.SqlSelectCommand41.CommandText = "[sp_GetIMGDocs]"
        Me.SqlSelectCommand41.CommandType = System.Data.CommandType.StoredProcedure
        Me.SqlSelectCommand41.Connection = Me.SqlConnection3
        Me.SqlSelectCommand41.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
        '

Then I just do a fill

  Ds_IMGDoc221.Clear()
        sqlGetIMGDocsAdapter.Fill(Ds_IMGDoc221)




Suggestions?

Thanks in advance
0
Comment
Question by:TimSweet220
  • 2
3 Comments
 
LVL 10

Assisted Solution

by:gangwisch
gangwisch earned 100 total points
ID: 18020488
the best suggestion i have is to databind the dataset from the dataadapter then do:
datagridview1.columns("Reference_Number").visible=false
when they select it datagridview1.item("Reference_Number",currentrowindex).value will equal what you need

Good Luck
0
 
LVL 5

Assisted Solution

by:proten
proten earned 400 total points
ID: 18021902
Why not set the text to the datafield you wish to display, and the value to the datafield value you wish to return

i.e.

dropdownlist1.DataSource = ds.tables(0)
dropdownlist1.DataTextField = "DataDisplay"
dropdownlist1.DataValueField = "DataValue"

This will send back the value that is transparent to the user when selected but display the display field to the user.
0
 
LVL 5

Accepted Solution

by:
proten earned 400 total points
ID: 18021919
ds is the DataSet with the data from your dataadapter

DataDisplay and DataValue are the names of the database fields returned,.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now