バインドしたいLinqの結果をDataGrid
に持っていますので、結果を編集できます。私が間違っていることについて助言してください。以下は、私のC#
コードです:LINQ結果をDataGridにバインド
var root = XElement.Parse(xmlText);
var elementsThatCanBeEmpty = new HashSet<XName>
{
XName.Get("Login"),
XName.Get("CustomerStreet2"),
XName.Get("PayeeStreet2"),
XName.Get("PayAsName"),
XName.Get("PayeeAccount")
};
var transactionList =
from transactions in root.Elements(XName.Get("Transactions")).Elements().AsEnumerable()
where transactions.Elements().Any
(
el =>
String.IsNullOrEmpty(el.Value) &&
!elementsThatCanBeEmpty.Contains(el.Name)
)
select transactions;
foreach (var t in transactionList)
{
Response.Write(t.Element(XName.Get("CustomerName")).Value);
}
dgBillPay.DataSource = transactionList;
dgBillPay.DataBind();
私はページを実行すると、データグリッドは "Value
、Xml
、HasAttributes
、HasElements
、IsEmpty
、Value
、BaseUri
" のヘッダーがあります。私はここで間違って何をしていますか?お知らせ下さい。