Click here to Skip to main content
16,004,578 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
C#
protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ProductModel productModel = new ProductModel();
        Product product = CreateProduct();

        lblResult.Text = productModel.InsertProduct(product);



    }


What I have tried:

C#
protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ProductModel productModel = new ProductModel();
        Product product = CreateProduct();

        lblResult.Text = productModel.InsertProduct(product);



    }
Posted
Updated 17-Apr-17 3:52am
v3
Comments
Richard MacCutchan 17-Apr-17 5:03am    
That code does not mean anything.
ZurdoDev 17-Apr-17 8:22am    
All you have to do is debug it. Very simple.

1 solution

I can only see (or suggest) one thing here,
C#
lblResult.Text = productModel.InsertProduct(product);

The InsertProduct function must return a string value, because the Text property of Label objects has a type of String, so either do that, or call a ToString function on the result, like,
C#
lblResult.Text = productModel.InsertProduct(product).ToString();

Secondly, from wherever you captured that code, you need to ask them why they wrote it this way. Also, you can change the code to the following one and would be a better approach,
C#
productModel.InsertProduct(product);
lblResult.Text = "Product added."

Much simple, and a better UX as well!
 
Share this answer
 
Comments
Ehsan Sajjad 17-Apr-17 8:45am    
5ed
Afzaal Ahmad Zeeshan 17-Apr-17 9:48am    
Thank you, Ehsan!

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