Reputation: 269
I got table with 1 row and 3 columns(date,time,what), I want 2 of the 3 columns(time,what) in my datasource how can i do that?
var table = (from r in socialEvents.AsEnumerable()
where r.Field<DateTime>("Date") >= Calendar1.SelectedDate.Date &&
r.Field<DateTime>("Date") <= Calendar1.SelectedDate.AddDays(1)
select r).CopyToDataTable();
if (table.Rows.Count > 0)
{
DataGrid1.Visible = true;
DataGrid1.DataSource = table;
DataGrid1.DataBind();
}
Upvotes: 0
Views: 129
Reputation: 3105
you can specify the columns in the select
var table = (from r in socialEvents.AsEnumerable()
where r.Field<DateTime>("Date") >= Calendar1.SelectedDate.Date &&
r.Field<DateTime>("Date") <= Calendar1.SelectedDate.AddDays(1)
select new {time = r.Field<DateTime>("Date"), what = r.Field<data_type>("what") });
Upvotes: 1
Reputation: 709
I'm assuming that datagrid is a GridView? then you should be to do something like this
<asp:GridView runat="server" AutoGenerateColumns="false" >
<Columns>
<asp:BoundField DataField="what" HeaderText="what" />
<asp:BoundField DataField="time" HeaderText="time" />
</Columns>
</asp:GridView>
Upvotes: 1