Hi I'm new to the grid, have followed documentation and samples, and have a problem with displaying data in the Grid. Should be easy but......
My web application has a service which goes out to a database and processes some tables (several un-joined) and returns a List<Thing> array of records. Each entry has an Integer property for ThingID, String property for ThingName, and String property ThingDescription as well as other stuff.
The concept is: The user wants to find things in a database and get a List<> of possible items to choose from. He/She then clicks the Grid row containing the Thing item of interest (record key is ThingID). The grid then posts back to the server for further processing of ThingID.
The grid has 3 columns 1 hidden and 2 visible -- the example Grid is read only items.
The grid displays the rows but where data should be they are empty cells.
Using ASP.NET 4.0, VS2012, linq, C#
Thing.cs - Items to display in grid
Code: C#
public class Thing
{
#region Properties
public int ThingID { get; set; }
public int OtherThingID { get; set; }
public String ThingName { get; set; }
public String Model { get; set; }
public String Manufacturer { get; set; }
#endregion
#region Custom Properties
public String ThingDescription
{ get
{ return (String.Format ("{0} {1}", Manufacturer, Model));
}
}
#endregion
}
Grid as defined in ThingControl.ascx file (I added KeyField -- made no difference)
Code: XML
<eo:Grid ID="Grid1" runat="server" Height="96px" Width="374px" BorderColor="#C7D1DF" BorderWidth="1px" ColumnHeaderAscImage="00050303" ColumnHeaderDescImage="00050304" ColumnHeaderDividerImage="00050302" FixedColumnCount="1" Font-Bold="False" Font-Italic="False" Font-Names="Verdana" Font-Overline="False" Font-Size="9pt" Font-Strikeout="False" Font-Underline="False" GridLineColor="199, 209, 223" GridLines="Both" ItemHeight="19" FullRowMode="False" KeyField="ThingID">
<ItemStyles>
<eo:GridItemStyleSet>
<ItemStyle CssText="background-color: white" />
<ItemHoverStyle CssText="background-image: url(00050206); background-repeat: repeat-x" />
<SelectedStyle CssText="background-image: url(00050207); background-repeat: repeat-x" />
<CellStyle CssText="padding-left:8px;padding-top:2px; color:#336699;white-space:nowrap;" />
</eo:GridItemStyleSet>
</ItemStyles>
<ColumnHeaderStyle CssText="background-image:url('00050301');padding-left:8px;padding-top:2px;font-weight: bold;color:white;" />
<Columns>
<eo:RowNumberColumn Visible="False"></eo:RowNumberColumn>
<eo:StaticColumn HeaderText="NAME" ReadOnly="True" Text="" Width="75"></eo:StaticColumn>
<eo:StaticColumn HeaderText="DESCRIPTION" ReadOnly="True" Width="-1"></eo:StaticColumn>
</Columns>
<ColumnTemplates>
<eo:RowNumberColumn DataField="ThingID">
</eo:RowNumberColumn>
<eo:StaticColumn DataField="ThingName">
</eo:StaticColumn>
<eo:StaticColumn DataField="ThingDescription">
</eo:StaticColumn>
</ColumnTemplates>
<FooterStyle CssText="padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px;" />
</eo:Grid>
Code behind ThingControl.ascx.cs
Code: C#
public partial class ThingControl : UserControl
{
protected void BindData()
{
Grid1.DataSource = IoC.Resolve(IThingService).GetThings(); // return List<Thing>
Grid1.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{ this.BindData();
}
}
}