Multiple fields from LINQ to Text Box

Posted by Chuki2 on Stack Overflow See other posts from Stack Overflow or by Chuki2
Published on 2012-11-02T16:56:42Z Indexed on 2012/11/02 17:01 UTC
Read the original article Hit count: 197

Filed under:
|
|

how can I pass value from selected field (LINQ) to textbox in winforms?

If single fields, I just do like this

   var result = from row in dtValueBranch.AsEnumerable()
                         where row.Field<int>("branchID") == idBranch
                         select row.Field<string>("branchName");

        StringBuilder sb = new StringBuilder();

        foreach (string s in result)
        {
            sb.Append(s + Environment.NewLine);
        }

        tbBranch.Text = sb.ToString();

So this is the code LINQ to many fields

    var result = from row in dtValueBranch.AsEnumerable()
                 where row.Field<int>("branchID") == idBranch
                 select new
                 {
                      BranchName = row["branchName"].ToString(),
                      branchTel = row["branchTel1"].ToString(),
                      // And many more fields

                 };

How can I to implement each fields to each textbox?

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms