Click here to Skip to main content
15,867,780 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i want to compare a value on basis of that value show output into listview

e.g. if id is 1 then 'A' this 'A' i have to display into listview.

How can i?

What I have tried:

VB
Public Sub load1()

    Dim SqlCommand As New SqlClient.SqlCommand
    Dim connection As String = ConfigurationManager.ConnectionStrings("strPROD").ConnectionString
    Dim con As New SqlConnection(connection)
    SqlCommand.CommandText = "prc_AllocatedUserInfo"

    SqlCommand.CommandTimeout = 0
    SqlCommand.Connection = con
    SqlCommand.CommandType = CommandType.StoredProcedure
    Dim sqlDA As New SqlDataAdapter(SqlCommand)
    SqlCommand.Parameters.Add("@AllocatedToUser", SqlDbType.VarChar).Direction = ParameterDirection.Input
    SqlCommand.Parameters("@AllocatedToUser").Value = username

    Dim ds As New DataSet()
    sqlDA.Fill(ds)

    'txt1.Text = ListView2.SelectedItems.Item(0).Text
    joblistview1.DataSource = ds.Tables(0)
    joblistview1.DataBind()

    con.Close()
End Sub


alter procedure prc_AllocatedUserInfo    
@AllocatedToUser varchar(Max)

as  
begin
select job.Id, job.CustClientLocID, JobCardMst.CardTypeRefId
from job inner join JobCardMst on job.id=JobCardMst.JobId  
inner join JobAllocation on JobAllocation.JobCardMstId=JobCardMst.Id   
where JobAllocation.AllocatedToUser =  @AllocatedToUser 
end
Posted
Updated 8-Aug-18 2:32am
v2
Comments
M4rLask 8-Aug-18 12:07pm    
I am not entirely clear about your environment, do you want to compare the value from your sql query? If so, you can use "Case"

Case
When ID=1 THEN 'A'
Else 'Your Valor' End
[no name] 8-Aug-18 23:33pm    
Each "row" will have a (job) "Id" column; so there can be "more than one A".

Where in the list view do you want to put all these "A's", eh?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900