|
Rank: Newbie Groups: Member
Joined: 9/2/2011 Posts: 5
|
Hello,
I just downloaded the web controls and I am trying to use the grid control. I have defined a grid on my page and then int he page load of my page, I am fetching data and assigning it to the grid.datasource property, however, the grid does not display anything. I have stepped through my code and confirmed that my data call is getting back data and the dataset does have data in it, but yet the grid still does not display anything. Am I missing something? My code is below, and your help is appreciated.
Thanks.
Markup code <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="DemoGrid2.aspx.vb" Inherits="APP360.DemoGrid2" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> Hello World <eo:Grid ID="Grid1" runat="server" GridLines="None"> <Columns> <eo:StaticColumn DataField="LName" HeaderText="Last Name"></eo:StaticColumn> <eo:StaticColumn DataField="symbol" HeaderText="symbol"></eo:StaticColumn> <eo:StaticColumn DataField="qty" HeaderText="Quantity"></eo:StaticColumn> <eo:StaticColumn DataField="price" HeaderText="Price"></eo:StaticColumn> <eo:StaticColumn DataField="value" HeaderText="Market Value"></eo:StaticColumn> </Columns> </eo:Grid> </div> </form> </body>
</html>
Code Behind Public Class DemoGrid2 Inherits PageBase
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ds As DataSet ds = DataClass.GetCData() Me.Grid1.DataSource = ds Me.Grid1.DataBind() End Sub
End Class
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
The Grid binds to a DataTable, not to a DataSet.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 9/2/2011 Posts: 5
|
Hi,
I tried your suggestion but still with no success. My code behind has been changed so that it now uses a datatable off of a dataview. If I check dv.table or Grid1.datasource while debugging, I do see the data, I just don't see the data render to the page. The page displays blank with no grid on it.
any thoughts?
Thanks.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ds As New DataSet ds = AppData.GetCFN360Data(51168, "647254", "", "", 0, "", "holding", "E", "Account")
Dim dv As DataView dv = ds.Tables(0).DefaultView
Me.Grid1.DataSource = dv.Table Me.Grid1.DataBind() End Sub
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
If the page is completely blank with nothing on it at all, then something else is wrong. You should at least see an empty Grid even if your data source is not working.
In order to display the Grid property, you must set the Grid's size and style. The easiest way to set it is to right click on the Grid, then select Edit Grid, then initialize the Grid from one of the built-in template (you can customize it later once you are familiar with all the properties). That should give you a blank Grid. Run the page and see if you see a blank Grid. If still nothing, then something is wrong with your application. In that case you can try to duplicate the problem in a separate test project and send the test project to us. We will be able to tell you what's wrong as soon as we see the problem.
You can also just copy the Grid definition from our sample project. That should work for you right away. The same project source code is installed on your machine when you install our product.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 9/2/2011 Posts: 5
|
Okay, so my issue was with the size. I was not specifically defining a size in pixels, as I was assuming a size was not required (like the regular .NET Datagrid or Gridview). I did notice, however, that I also cannot define the size as 100%, i.e., that I need to specify the size in pixels. Is that true?
thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
I believe you can use 100% --- as soon as its parent's size is known, which makes it not very useful. Also 100% is always tricky even with regular HTML element, so I would avoid that. In all cases using fixed pixel size would give you the best result because internally the Grid optimizes a number of things based on its pixel size when its pixels size is known.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 9/2/2011 Posts: 5
|
Thanks.
|
|