Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Cannot assign because it is a method group

Posted on 2013-10-26
1
2,048 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Suggested Solutions

Title # Comments Views Activity
use of unassigned local variable 'id' 6 53
Best resource to learn entity framework 2 47
Printing 1 58
C# Gridview 1 47
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

860 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