朋友们,我正在使用一层层次结构网格。我正在做如下代码
protected DataSet GenerateRadGrid()
{
DataSet dsCollective = new DataSet();
DataSet dsFirst = Library.ExecuteTag("SelectEHRMessage");
if (dsFirst.HasRows())
{
DataTable dt = new DataTable();
dt = dsFirst.Tables[0].Copy();
dt.TableName = "MainMessage";
dsCollective.Tables.Add(dt);
foreach (DataRow row in dsCollective.Tables["MainMessage"].Rows)
{
var rootMessageID = row["MessageID"].ToFormatedInt64();
DataSet dsSecond = Library.ExecuteTag("SelectParentReply", new KeyValuePair<string, object>("@0", rootMessageID));
dsSecond.Tables[0].TableName = "MainReplies-" + rootMessageID;
dsCollective.Tables.Add(dsSecond.Tables[0].Copy());
DataRelation mainMessageRepliesRelation = new DataRelation("MainMessageReplies-" + rootMessageID, dsCollective.Tables["MainMessage"].Columns["MessageID"], dsCollective.Tables["MainReplies-" + rootMessageID].Columns["MessageID"]);
dsCollective.Relations.Add(mainMessageRepliesRelation);
}
}
return dsCollective;
}
这是返回我与网格绑定的数据集的函数。现在的问题是网格也显示了我的空记录。我的意思是其中的关系不存在。如下:
现在我必须在代码中进行更改以避免那些“没有要显示的子记录”行。有适合我的房产吗?