<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetObjects" TypeName="ControlPanelMessages">
</asp:ObjectDataSource>
What i need is to put two items into one row.. The Img and the Name should be in the same row.
How do I achieve that?
Update..can I do this:
DataRow newRow = table.NewRow();
// Set values in the columns:
newRow["Img"] = "NewCompanyImage";
newRow["Img"] = "NewCompanyName";
will it put both values in the same row?
Thats what i did:
public DataSet GetObjects()
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
var source = from p in CommentsList
select new { p.Img, p.Name, p.Comment };
dt.Columns.Add("User");
dt.Columns.Add("Comment");
foreach (var item in source)
{
DataRow UserDetailsRow=dt.NewRow();
UserDetailsRow["User"] = item.Img;
UserDetailsRow["User"] = item.Name;
UserDetailsRow["Comment"] = item.Comment;
// dt.Rows.Add(new object[] { item.Img, item.Name, item.Comment });
}
ds.Tables.Add(dt);
return ds;
}
Is this the right way?
You haven’t added any columns to the data table yet, you’ll need to do
for each column you want in there before you add a row.