Solved

Cannot assign because it is a method group

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now