0

I am getting the following error working on gradrid footer totals "'fitem' is a 'variable' but is used like a 'method'"

protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridFooterItem)
    {
        GridFooterItem fitem = (e.Item as GridFooterItem);
        string value1 = fitem("CALENDAR_DAYS_MTD").Text;
        string value2 = fitem("WEEKENDS_MTD").Text;
        string value3 = fitem("HOLIDAYS_MTD").Text;
        string value4 = fitem("BUSINESS_DAYS_MTD").Text;
        int footervalue1 = Convert.ToInt32(value1.Split(':')[1]);
        int footervalue2 = Convert.ToInt32(value2.Split(':')[1]);
        int footervalue3 = Convert.ToInt32(value3.Split(':')[1]);
        int footervalue4 = Convert.ToInt32(value4.Split(':')[1]);
        //to get the value only.
        if (footervalue2 + footervalue3 + footervalue4 > footervalue1)
        {
            fitem("WEEKENDS_MTD").Style("color") = "Black";
            fitem("HOLIDAYS_MTD").Style("color") = "Black";
            fitem("BUSINESS_DAYS_MTD").Style("color") = "Black";


        }
        else
        {
            fitem("WEEKENDS_MTD").Style("color") = "Red";
            fitem("HOLIDAYS_MTD").Style("color") = "Red";
            fitem("BUSINESS_DAYS_MTD").Style("color") = "Red";
        }
    }
}
4
  • 1
    You could have at least tagged your question with the library you are using. Looks like Telerik or something. Commented Aug 22, 2012 at 20:38
  • 1
    Welcome to Stack Overflow! Please edit your post to ask an actual question. Currently you are just stating that you are getting an error message. What have you done to troubleshoot this problem? Tell us what you want know. Commented Aug 22, 2012 at 20:39
  • I removed the Telerik tag. This has nothing to do with Telerik (assuming that GridFooterItem was not somehow a magical subclass of Func, which it is not .. object x = new object(); x("foo") would have resulted in the syntax error.) Commented Aug 22, 2012 at 21:02
  • I am getting an 'IndexOut of Range Exception' on the string conversion any ideas? Commented Aug 22, 2012 at 21:09

4 Answers 4

5

Your lines

fitem("WEEKENDS_MTD").Style("color") = "Black";

should probably be

fitem["WEEKENDS_MTD"].Style["color"] = "Black";

since the [] brackets are for accesing an index and the () brackets are used to call methods.

Sign up to request clarification or add additional context in comments.

Comments

0

You have this:

 GridFooterItem fitem = (e.Item as GridFooterItem);
 string value1 = fitem("CALENDAR_DAYS_MTD").Text;

Using fitem("CALENDAR_DAYS_MTD") likely should be fitem["CALENDAR_DAYS_MTD"].

Comments

0

As long as you're using C#, you should be using square brackets rather than parenthesis for referencing indexes.

fitem["WEEKENDS_MTD"].Style["color"] = "Black";

VB.NET uses the parenthesis for indexes.

1 Comment

@Servy - Yep. Meant to type it but apparently my fingers didn't listen to my brain.
0

I think you're thinking of VB.NET, which uses parentheses to index, but this is C#. It should be:

fitem["CALENDAR_DAYS_MTD"].Text // Note the square brackets replacing the parens.

Not:

fitem("CALENDAR_DAYS_MTD").Text 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.