Hi all,
i need some help in c# in order to display the attrtibute that is not in the same table..
i have a table COMPANY and CODE..in company table, i have attribute called CmpStatusCode that just display in int (input by ddl which is selectedvalue ex: 1,2,3)..but in CODE table, there are definition for that selectedvalue (ex: 1=active , 2=not active).. what should i do to display the value of "active" by refering to 1,2,3? i'm using usp..
i'm using datagrid to display the data..

<asp:TemplateColumn HeaderText="Status"  HeaderStyle-Width="5%"  SortExpression="CmpStatusCode" visible="true">
    <ItemTemplate>
    <center><asp:Label Id="lblCmpStatusCode" width="50px" Text='<%# DataBinder.Eval(Container, "DataItem.CmpStatusCode") %>' Runat="server"  /></center>
    </ItemTemplate>
</asp:TemplateColumn>

this is my usp

begin
		SELECT CmpID, 
			   CmpCode, 
			   CmpName, 
			   CmpEffDate, 
			   CmpExpDate, 
			   CmpStatusCode 
			   from ms_Company
	end

now, when the page is build, value for CmpStatusCode will be in 1,2,3.. i could not find the way to display the value for 1,2,3 that need to be refer in table code.. in Code table, the attribute that explain the CmpStatusCode is CodCode..

anybody please help me.. sorry for the bad english.. i dont know how to explain it:sad:

i have continued my research and found the solution..tq

Member Avatar for siju kuriakose

Hi,
Pls return the status according to the integer value by using a switch case in sql query or use conditional operator in databinding to grid view
hope your reply

if(@sqltype = 'datagrid')
	begin
		SELECT CmpID, 
			   CmpCode, 
			   CmpName, 
			   CmpEffDate, 
			   CmpExpDate, 
			   CmpStatusCode,
			   CodCode 
			   from ms_Company C, ms_Code D
			   where C.CmpStatusCode = D.CodID
	end

this is what i have done, is it possible?

Member Avatar for siju kuriakose

Hi,
If CmpStatusCode is a required field (means it is not null) joining of tables is better always.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.