0

Hi I started a project for a class, where I have to create a SQL data base and using stored procedure extract the values according to 3 drop down lists and bind it to a Gridview. Up to here I am ok where I am stuck is that once the data has been bind I have to calculate the totals of certain cells within the grid view. So my teacher told me I would have to create some variables and have it in the RowDataBind event and here is where I run into problems. here is the code I have so far:

    budgetedTotal = ((Label)e.Row.FindControl("Budgeted_TCV")).Text;
    if (budgetedTotal != null && budgetedTotal != "") 
    {
         budgetedTotal = budgetedTotal +Convert ToUInt32(budgetedTotal);
    }
    else
    {
         budgetedTotal = budgetedTotal + 0;
    }

    Label lblProjectType = (Label)e.Row.FindControl("lblProjectType");
    lblProjectType.Text = budgetedTotal; 

    }

Thanks any help is super welcomed or any other ideas at this point I am open to anything.

  • You have some code, and you said you ran into problems. But you didn't describe what those problems are, which means that your question is too broad and basically saying "fix this for me", which won't fly on SO. Instead, describe what it's doing wrong, and what you want it to do. – mason Apr 06 '15 at 00:53
  • Sorry I totally forgot to include those details, ok so the code I have provided is my newest attempt, before I had it extracting the value but it would only extract the first value which are the titles of the columns, so after speaking to my professor he told me to do something similar to what I have now. So now the issue I run into is "Object Reference not set to an instance of an object" Which has me debating if i'm attacking the problem the correct way. – user3363109 Apr 06 '15 at 00:58
  • The `NullReferenceException` you're getting is a common problem, and an [easy one to solve](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it). Basically, in this case you're trying to access a property on a variable that's null because it didn't get initialized correctly. – mason Apr 06 '15 at 01:00

0 Answers0