Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

DataGridView.DataMember property not behaving as explained in Class description

$
0
0

Hello,

Developing a C sharp Windows Forms program in VS 2013 Pro to consume a web service.

When I run this program:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using LakesideConsumeServices.LakesideServiceReference;

namespace LakesideConsumeServices
{
    public partial class Form1 : Form
    {
        int rowCountInt = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void downloadCustomersButton_Click(object sender, EventArgs e)
        {
            NopServiceClient serviceClient = new NopServiceClient();
            string[] queryString = new string [] {"Select Top 120 * From [Customer]"};
            dataGridView1.DataSource = serviceClient.ExecuteDataSet(queryString, "xxx@yyyy.com", "password");
            dataGridView1.DataMember="Table1";
            MessageBox.Show("Row count = " + rowCountInt);
        }

        private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            rowCountInt += 1;
        }
    }
}

It displays 120 records/rows in the dataGridView1.

If I remove this line,

dataGridView1.DataMember="Table1";

and run it, the dataGridView1 does not get populated.

I'm puzzled about that, because when I read this information: http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.datamember.aspx

it says that the DataMember is not required when there is only one table.

Is the DataMember property required or not?

Any help Would be gratefully appreciated.

Thanks,
Tony


Stop The World, I want To Get Off! ........... Life Isn't About Waiting For The Storm To Pass ... It's About Learning To Dance In The Rain.




Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>