Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8463381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:26:19+00:00 2026-06-10T14:26:19+00:00

i want to bind gridview with my custom entity whitch i populate from data

  • 0

i want to bind gridview with my custom entity whitch i populate from data base
but i get error
Object reference not set to an instance of an object
i know the error is from my gridlink class
when select new and want to set to link property
in this line : link = { linkName = "tyr", linkSrc = "ytr" },
because when i earase it the error stop and gridview bind
thanks

  public class gridcolumns
{

    public decimal cost { get; set; }
    public Int32 count { get; set; }
    public gridlink link { get; set; }

    public gridcolumns()
    {

        // TODO: Complete member initialization
    }
}

public class gridlink
{
    public string linkName { get; set; }
    public string linkSrc { get; set; }

    public gridlink()
    {

    }
}
 protected void Page_Load(object sender, EventArgs e)
{
    Data281DataContextDataContext conx = new Data281DataContextDataContext();
    List<tbl_2_CheckReqNo_NotValid> allresult = conx.tbl_2_CheckReqNo_NotValids.ToList();
    gridcolumns lastMantWithDate = new gridcolumns();
    if (Request.QueryString.Count == 0)
    {
        var lastMantWithDaste = from pe in allresult //where allresult != null
                                orderby Convert.ToDecimal(pe.mandeh) descending
                                group pe by pe.mant into grouped
                                where grouped != null
                                select new gridcolumns
                                {
                                    link = { linkName = "tyr", linkSrc = "ytr" },
                                    cost = grouped.Sum(g => Convert.ToDecimal(g.mandeh)),
                                    count = grouped.Count(),

                                };

        GrdOstan.DataSource = lastMantWithDaste;
        GrdOstan.DataBind();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:26:20+00:00Added an answer on June 10, 2026 at 2:26 pm

    You should be instantiating a gridlink like this:

    link = new gridlink { linkName = "tyr", linkSrc = "ytr" },
    

    Consider that for each item your query produces you create a gridcolumns object. The link property of that object is initially null; you should set it to new gridlink before trying to use it at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi i want to Bind GridView with images from the sd-card but not in
I want to bind dropdown list in a gridview with datasiursce coming from data
I want to bind the datasource to GridView,but it doesn't work,because the datasource is
i want to get the Id from GridView in RowDeleting Event , I tried
I want to bind a MySQL database to my WPF GridView. But this doesn't
I want to bind my gridview with my SQL query that is my data
I have a gridview that it bind to a data table.I want to add
I want to bind a function to an event but I want to change
I want to bind a string value to a text box but only if
I want to bind Groupboxes to my stackpanel. c#: internal ObservableCollection<GroupBox> BindingTest { get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.