Here's the code that I'm trying to send the dataset to...maybe there's just a couple of changes that could make it work with a DataView?
int i = 0;
string prevsub = "";
while (i <= ds.Tables[0].Rows.Count - 1)
{
DataRow dr = ds.Tables[0].Rows[i];
string sub = dr["SubHeading"].ToString();
if (sub != prevsub)
{
prevsub = sub;
DataRow newrow = ds.Tables[0].NewRow();
newrow["Title"] = "SubHeading";
newrow[columnName] = dr[columnName];
ds.Tables[0].Rows.InsertAt(newrow, i);
i++;
}
i++;
}
DataView is very close to the dataset object in this context.
my test code:
DataView dv = (DataView) SqlDataSource1.Select(DataSourceSelectArguments.Empty);
int i = 0;
string prevsub = "";
while (i <= dv.Table.Rows.Count - 1)
{
DataRow dr = dv.Table.Rows[i];
string sub = dr["mycol1"].ToString();
if (sub != prevsub)
{
prevsub = sub;
DataRow newrow = dv.Table.NewRow();
newrow["mycol1"] = "SubHeading";
newrow["mycol2"] = dr["mycol2"];
dv.Table.Rows.InsertAt(newrow, i);
i++;
}
i++;
}
Hope this helps.
|||Hi there. Thanks so much limno! That did the trick. I was hoping that the dv would be similar enough to be able to use this code. Great to know and use for the future. Much appreciated!
No comments:
Post a Comment