开发者

Problem with datatable bound to a datagridview

I've a datatable bound to a gridview.

The datatable has the following data:

JobID   Site    Job List
---------   ---------   ---------   ---------
134 A   job1    26
2241    A   job2    25
124 A   job3    26
244 B   job1    12
154 B   ads2    46

Am trying to take the count of distinct sites. So I write the following function:

    public void CreateAdmins(DataTable JobsToStart)
    {
        DataView uniqueDialers = new DataView(JobsToStart);
        uniqueDialers = uniqu开发者_如何学GoeDialers.ToTable(true, "Site").DefaultView;
        Debug.Print(uniqueDialers.Rows.Count);
    }

After executing the above function the data which is displayed in the datagridview changes. How do I avoid this?


If I understand your question correctly...

Assign it to a different variable. The datagrid is looking at the same object that you are later modifying using this function. This is because it has been 'passed by reference'. Have a look at this article for info on that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜