Click here to Skip to main content
15,937,012 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Actually i'm having one user control called Account.
I need to use this control for various textboxes.

For Example..

C#
InsurerName = (TextBox)(AssetInsurer.FindControl("Account"));
InsurerID = (TextBox)(AssetInsurer.FindControl("AccountID"));
SoldName = (TextBox)(AssetSales.FindControl("Account"));
SoldID = (TextBox)(AssetSales.FindControl("AccountID"));


In the above code i need to use same user control Accout for both insurer ans sales.


Here is my aspx code.....

XML
<%@ Register TagPrefix="CC2" TagName="Manufacturer" Src="~/UserControls/WUCAccount.ascx" %>
..............
................
.................

<tr>
    <td class="label">
        <asp:Label ID="LblSoldTo" runat="server" Text="Sold To :" meta:resourceKey="LblSoldTo"></asp:Label>
    </td>
    <td>
        <CC2:Manufacturer ID="AssetSales" runat="server" TabIndex="132"></CC2:Manufacturer>
    </td>
    <td class="label">
        <asp:Label ID="LblInsurerID" runat="server" Text="Insurer Id :" meta:resourceKey="LblInsurerID"></asp:Label>
    </td>
    <td>
        <CC2:Manufacturer ID="AssetInsurer" runat="server" TabIndex="132"></CC2:Manufacturer>
    </td>
</tr>
..............
.................
....................


while executing the code in the .cs page i'm getting the error as
"
Object reference not set to an instance of an object.
"
in the below lines:


if (InsurerID.Text != "0")
{
	LQMasterAssetDataContext CDbIN = new LQMasterAssetDataContext();
	TB_MasterAssetInsurer AssInsurer = CDbIN.TB_MasterAssetInsurers.FirstOrDefault(C => C.mAIN_NUPKId == mobjGenlib.ConvertLong(InsurerID.Text));
	InsurerName.Text = AssInsurer.mAIN_VCAgentname;
}

if (SoldID.Text != "0")
{
	LQMasterAssetDataContext CDbIN = new LQMasterAssetDataContext();
	TB_MasterAsset AssSoldto = CDbIN.TB_MasterAssets.FirstOrDefault(C => C.mASS_NUPKId == mobjGenlib.ConvertLong(SoldID.Text));
	SoldName.Text = AssSoldto.mASS_mACC_NUPKId_Soldto.ToString();
}


Please help me to resolve this thanks in advance.
Posted
Updated 5-Mar-14 18:03pm
v2

 
Share this answer
 
Hi
Sorry I made a mistake. Actually in the below code.

if (InsurerID.Text != "0")
{
	LQMasterAssetDataContext CDbIN = new LQMasterAssetDataContext();
	TB_MasterAssetInsurer AssInsurer = CDbIN.TB_MasterAssetInsurers.FirstOrDefault(C => C.mAIN_NUPKId == mobjGenlib.ConvertLong(InsurerID.Text));
	InsurerName.Text = AssInsurer.mAIN_VCAgentname;
}
 
if (SoldID.Text != "0")
{
	LQMasterAssetDataContext CDbIN = new LQMasterAssetDataContext();
	TB_MasterAsset AssSoldto = CDbIN.TB_MasterAssets.FirstOrDefault(C => C.mASS_NUPKId == mobjGenlib.ConvertLong(SoldID.Text));
	SoldName.Text = AssSoldto.mASS_mACC_NUPKId_Soldto.ToString();
}


Instead of connecting to the Account table
(TB_MasterAccount)
i wrongly given its own table name as
(TB_MasterAsset
and
TB_MasterInsurer


Once i changed the above things it was working fine.
 
Share this answer
 

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