The value of the first 2 columns for all the rows are the same. how can i use asp.net to display the info look something like this

i called a sql query to a view and return the records below.

PID     Description     PInfoName     pInfoValue
888     Portable PC     Model ID     p909
888     Portable PC     CPU          P4 3.4G
888     Portable PC     Memory          2G RAM

The value of the first 2 columns for all the rows are the same.  how can i use asp.net to display the info look something like this
General Info:
PID     Description
888     Portable PC

Product details info:
Model ID     p909
CPU            P4 3.4G
Memory      2G RAM    
musclejackAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arif_eqbalCommented:
You are taking the case of only one item
i.e. when PID=888
what if there are 6 records 3 for PID=888 as you have shown
and three for PID=999

Then how would you like to show???
One way is you canhave the PID and Description in one dataGrid and the rest info on the other datagrid
When user selects a row in top Datagrid the bottom one gets populated with details of the particular PID

OR

you can have a Combobox and a Dtatgrid

0
musclejackAuthor Commented:
can u give me an simple example?  thx
0
arif_eqbalCommented:
OK here goes...

What I have done is Add One ComboBox to a Form and Named it CmbPID
And Added a dataGrid called DetailsdataGrid

Then, At Form level declare

    Dim DTDetails As DataTable
    Dim ConStr As String="Provider=..... YOUR CONNECTION STRING ...."

    'On Form Load Call the Function FillData
    Private Sub FrmTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        FillData()
    End Sub

  'FillData Loads the PID and the Description in a Combo Box. It loads all the unique PIDs
    Private Sub FillData()
        Dim DR As OleDbDataReader
        Dim Cn As OleDbConnection = New OleDbConnection(ConStr)
        Dim Cmd As OleDbCommand = New OleDbCommand("Select Distinct PID, Description From Mytable", Cn) 'Remember the keyword DISTINCT
        'The Qurery will change based on the exact table and Column Names
        Cn.Open()
        DR = Cmd.ExecuteReader
        Do While DR.Read
            Me.CmbPID.Items.Add(DR(0) & " " & Dr(1))
        Loop
        DR.Close()
        Cn.Close()
    End Sub

   'Now Whenever you select a PID from the Combo, This event is fired. here we fill the DataGrid with the
'Details of that particular PID which was selected in the Combo
    Private Sub CmbPID_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbPID.SelectedIndexChanged
        DTDetails = New DataTable
        Dim DA As OleDbDataAdapter = New OleDbDataAdapter("Select PInfoName,PInfoValue From Mytable Where PID='" & Me.CmbPID.Text & "'", ConStr)
        DA.Fill(DTDetails)
        Me.DetailsDataGrid.DataSource = DTDetails
    End Sub


That's it
I have just assumed a Table named MyTable with 4 columns as mentioned by you
0
arif_eqbalCommented:
A small background what this whole thing will do

We'll have a form with one Combo Box and One DataGrid
ComboBox will have All PIDs and Desctiption eg
888 Portable PC    
999 LapTop

Then whenever you select an Item from the Combo Say 888, the dataGrid will show all the details of it like


Model ID     p909
CPU            P4 3.4G
Memory      2G RAM  

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.