Solved

Cannot assign because it is a method group

Posted on 2013-10-26
1
2,063 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 44

Accepted Solution

by:
AndyAinscow earned 500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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