[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Cannot assign because it is a method group

Posted on 2013-10-26
1
Medium Priority
?
2,167 Views
Last Modified: 2013-10-26
Hi Experts,

On Gridview keydown my code is as below

private void DgridKeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode != Keys.Enter)) return;
            var selectedrowindex = Dgrid.CurrentCell.RowIndex;
            if (((selectedrowindex + 1) == Dgrid.Rows.Count)) return;
            if (Dgrid.CurrentRow == null) return;
            LoadControlsFromGridView = Convert.ToString(Dgrid.CurrentRow.Cells["TitleID"].Value);
            
        }

Open in new window


Then the function
 private void LoadControlsFromGridView(string titleId)
        {
            _dt.RowFilter = "TitleID= " + titleId + "";
            Tbxdescription.Text = Convert.ToString(_dt[0]["Description"]);
            _dt.RowFilter = "";
        }

Open in new window


The line LoadControlsFromGridView = Convert.ToString(Dgrid.CurrentRow.Cells["TitleID"].Value); give an error Cannot assign because it is a method group.

I know that I can create a variable and then in next line pass the variable to function. I am just trying to avoid creating a variable so that I can save one line of code :)

Any idea how can i over come this error?
0
Comment
Question by:GRChandrashekar
1 Comment
 
LVL 45

Accepted Solution

by:
AndyAinscow earned 2000 total points
ID: 39602624
instead of
LoadControlsFromGridView = Convert.ToString(Dgrid.CurrentRow.Cells["TitleID"].Value);
           
how about calling the function (rather than attempting to assign a value)
LoadControlsFromGridView( Convert.ToString(Dgrid.CurrentRow.Cells["TitleID"].Value) );
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question