Click here to Skip to main content
15,905,616 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to pass data to label and display in UI? That data is in SP

I used 3 tier architecture. In Data access layer

Set @meassage="Record Inserted SucessFully";

C#
cmd.Parameters.Add("@Message", SqlDbType.VarChar, 500);
cmd.Parameters["@Message"].Direction = ParameterDirection.Output;

int result=  cmd.ExecuteNonQuery();
string outputValue = cmd.Parameters["@Message"].Value.ToString();
if (result == 1)
{
    lbloutputdata.text = outputValue;
}


This is not in .aspx.cs page . that code is in data acess layer

Any one help me ...
Posted

You have to return that from the method in data access layer. Then just assign the returned string to the Label.
 
Share this answer
 
Comments
Sai Prasad anumolu 11-Oct-14 7:38am    
I already returned friend

cmd.Parameters.Add("@Message", SqlDbType.VarChar, 500);
cmd.Parameters["@Message"].Direction = ParameterDirection.Output
string outputValue = cmd.Parameters["@Message"].Value.ToString();
This is class DAL .

This is .aspx.cs i want output value is call in label.text How ?
lbloutputData.Text = ObjectRepresentDL.outputValue;
That code should be inside a method, right? Add a return type to that method, which will be string, like...

string MethodInDAL()
{
//......., other codes....
cmd.Parameters.Add("@Message", SqlDbType.VarChar, 500);
cmd.Parameters["@Message"].Direction = ParameterDirection.Output
string outputValue = cmd.Parameters["@Message"].Value.ToString();

return outputValue;
}

Now in aspx.cs...

lbloutputData.Text = MethodInDAL();

Got me?
Sai Prasad anumolu 11-Oct-14 8:07am    
i already i return return ObjectRepresentDL; This one DAl
So, what is the issue. Have you not assigned the message to this object?
Sai Prasad anumolu 11-Oct-14 8:18am    
Issue means .. how to store the value in Class ?(This is class) + That stored value will call to label.text

label.text= Stored value. I used 3 tier architecture
create a class file for message box
as example
message.cs in bll
C#
public void ShowAlertMessage(string error)
    {

        Page page = HttpContext.Current.Handler as Page;

        if (page != null)
        {

            error = error.Replace("'", "\'");

            ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", "alert('" + error + "');", true);

        }
    }


and place the code.

now you add your serverside


C#
message msg = new message();

cmd.Parameters.Add("@Message", SqlDbType.VarChar, 500);
cmd.Parameters["@Message"].Direction = ParameterDirection.Output;
 
int result=  cmd.ExecuteNonQuery();
if (result >= 1)
{
    msg.Showalertmessage("Your Message!..");
}
 
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