Solved

Cannot assign because it is a method group

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

777 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