|
Rank: Advanced Member Groups: Member
Joined: 2/20/2008 Posts: 34
|
(sorry, we got off on a tangent and this question never got answered)
I put an EO grid and a GridView on an empty page an add a sqldatasource. I connect the DataSourceID property to both controls. I have a textbox and a button with the following code in it
protected void Button1_Click(object sender, EventArgs e) { Session["ProductGroup"] = TextBox1.Text; Grid1.DataBind(); GridView1.DataBind(); } The GridView binds. The EO Grid Does not. Why not.
Thanks, Gary
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi Gary,
I believe we have already explained this to you in our original post. The short answer for this is that the two are very different products. So it's not unusual that one product does not have something the other one has. Obviously it's our attention to have them work similar so that the learning curve for you would be as low as possible, but sometimes this is not possible. It's like a race car doesn't have an automatic shift. In order to get some, sometimes you have to give up some.
Please go over the document as how to bind our Grid, it has been explained in great detail there. If you run into some problems over there, we would be happy to help.
Also, please do not post the same questions repeatly within a short period of time. Many users considered it annoying so it is not a welcome behavior in our forum.
Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 2/20/2008 Posts: 34
|
(it seems when I post a repley to a reply it never gets posted or answered so I'm not sure I'm doing this right)
I have read all of your docs on databinding. It says that one accepted method is to bind to a datatable. I have dozens of already written methods that return datatables and I am trying to use your Grid with them. I have tried Grid1.datasource = mytable and Grid1.datasource = mytable.defaultview. nothing seems to work I can't seem to get your grid to bind to a datatable.
I'm under some pressure to find a control for a new project so I hope you get this post.
Your docs always show an executereader returning an OleDbDataReader but never a datatable. What am I doing wrong? Thanks, Gary
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi Gary, You will always need to choose a running mode and define columns first: http://www.essentialobjects.com/ViewDoc.aspx?t=Grid%2fmode.htmlhttp://www.essentialobjects.com/ViewDoc.aspx?t=Grid%2fcolumns.htmlI do not believe there is any difference between populating from a DataTable or a DataReader. The code should be the same. Thanks
|
|
Rank: Advanced Member Groups: Member
Joined: 2/20/2008 Posts: 34
|
I can't get data into this grid.
First, if I click on the grid in design and select edit columns I get a box that says object reference not set to an instance of an object. If I click on edit grid I do get the designer. I then created three columns. The running mode is set to client.
(I cannot add a maskeditbox as when I select that from the dropdown the designer completely disapears so I am just using testboxes)
The grid still appears empty with no data (the gridview binds fine)
Code and grid are pasted below. Hope you can help. Gary
The following code is in page load...
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable mytable = DBMethods.GetBranches(3); Grid1.DataSource = mytable; <--I checked the table and it has data Grid1.DataBind(); GridView1.DataSource = mytable; <--the data shows fine in the gridview GridView1.DataBind(); } }
here is the grid.... <eo:Grid ID="Grid1" runat="server" BorderColor="#828790" BorderWidth="1px" ColumnHeaderAscImage="00050204" ColumnHeaderDescImage="00050205" ColumnHeaderDividerImage="00050203" ColumnHeaderHeight="24" DataSourceID="SqlDataSource1" FixedColumnCount="1" Font-Bold="False" Font-Italic="False" Font-Names="Tahoma" Font-Overline="False" Font-Size="8.75pt" Font-Strikeout="False" Font-Underline="False" GridLineColor="240, 240, 240" GridLines="Both" Height="200px" ItemHeight="19" Width="480px"> <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;" /> </eo:GridItemStyleSet> </ItemStyles> <ColumnTemplates> <eo:TextBoxColumn> <TextBoxStyle CssText="BORDER-RIGHT: #7f9db9 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #7f9db9 1px solid; PADDING-LEFT: 2px; FONT-SIZE: 8.75pt; PADDING-BOTTOM: 1px; MARGIN: 0px; BORDER-LEFT: #7f9db9 1px solid; PADDING-TOP: 2px; BORDER-BOTTOM: #7f9db9 1px solid; FONT-FAMILY: Tahoma" /> </eo:TextBoxColumn> <eo:DateTimeColumn> <DatePicker ControlSkinID="None" DayCellHeight="16" DayCellWidth="19" DayHeaderFormat="FirstLetter" DisabledDates="" OtherMonthDayVisible="True" SelectedDates="" TitleLeftArrowImageUrl="DefaultSubMenuIconRTL" TitleRightArrowImageUrl="DefaultSubMenuIcon"> <TodayStyle CssText="font-family: tahoma; font-size: 12px; border-right: #bb5503 1px solid; border-top: #bb5503 1px solid; border-left: #bb5503 1px solid; border-bottom: #bb5503 1px solid" /> <SelectedDayStyle CssText="font-family: tahoma; font-size: 12px; background-color: #fbe694; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" /> <DisabledDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" /> <PickerStyle CssText="border-bottom-color:#7f9db9;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#7f9db9;border-left-style:solid;border-left-width:1px;border-right-color:#7f9db9;border-right-style:solid;border-right-width:1px;border-top-color:#7f9db9;border-top-style:solid;border-top-width:1px;font-family:Courier New;font-size:8pt;margin-bottom:0px;margin-left:0px;margin-right:0px;margin-top:0px;padding-bottom:1px;padding-left:2px;padding-right:2px;padding-top:2px;" /> <CalendarStyle CssText="background-color: white; border-right: #7f9db9 1px solid; padding-right: 4px; border-top: #7f9db9 1px solid; padding-left: 4px; font-size: 9px; padding-bottom: 4px; border-left: #7f9db9 1px solid; padding-top: 4px; border-bottom: #7f9db9 1px solid; font-family: tahoma" /> <TitleArrowStyle CssText="cursor:hand" /> <DayHoverStyle CssText="font-family: tahoma; font-size: 12px; border-right: #fbe694 1px solid; border-top: #fbe694 1px solid; border-left: #fbe694 1px solid; border-bottom: #fbe694 1px solid" /> <MonthStyle CssText="font-family: tahoma; font-size: 12px; margin-left: 14px; cursor: hand; margin-right: 14px" /> <TitleStyle CssText="background-color:#9ebef5;font-family:Tahoma;font-size:12px;padding-bottom:2px;padding-left:6px;padding-right:6px;padding-top:2px;" /> <OtherMonthDayStyle CssText="font-family: tahoma; font-size: 12px; color: gray; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" /> <DayHeaderStyle CssText="font-family: tahoma; font-size: 12px; border-bottom: #aca899 1px solid" /> <DayStyle CssText="font-family: tahoma; font-size: 12px; border-right: white 1px solid; border-top: white 1px solid; border-left: white 1px solid; border-bottom: white 1px solid" /> </DatePicker> </eo:DateTimeColumn> <eo:MaskedEditColumn> <MaskedEdit ControlSkinID="None" TextBoxStyle-CssText="BORDER-RIGHT: #7f9db9 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #7f9db9 1px solid; PADDING-LEFT: 2px; PADDING-BOTTOM: 1px; MARGIN: 0px; BORDER-LEFT: #7f9db9 1px solid; PADDING-TOP: 2px; BORDER-BOTTOM: #7f9db9 1px solid; font-family:Courier New;font-size:8pt;"> </MaskedEdit> </eo:MaskedEditColumn> </ColumnTemplates> <FooterStyle CssText="padding-bottom:4px;padding-left:4px;padding-right:4px;padding-top:4px;" /> <Columns> <eo:RowNumberColumn> </eo:RowNumberColumn> <eo:TextBoxColumn HeaderText="Company" Name="Company"> </eo:TextBoxColumn> <eo:TextBoxColumn HeaderText="branch" Name="branch"> </eo:TextBoxColumn> <eo:TextBoxColumn HeaderText="branchname" Name="branchname"> </eo:TextBoxColumn> </Columns> <ColumnHeaderStyle CssText="background-image:url('00050201');padding-left:8px;padding-top:4px;" /> <ColumnHeaderHoverStyle CssText="background-image:url('00050202');padding-left:8px;padding-top:4px;" /> </eo:Grid>
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Did you set each column's DataField property?
|
|
Rank: Advanced Member Groups: Member
Joined: 2/20/2008 Posts: 34
|
Well, I didn't but now I do have them set and there is no difference. The three textbox columns have their datafield property set to the field name being returned in the datatable: companyid, branch, and branchname. Grid is empty.
I'm running your demo site which executes fine on my system (but grids won't render in designtime) and the only difference is that I'm trying to bind from a datatable instead of execute reader. Gary
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi, As a test, you can try to copy the sample code that creates a DataTable from this sample: http://www.essentialobjects.com/Demo/Default.aspx?path=Menu\menu_programming\_i0\binding_datatableCopy the CreateDataTable function and then: 1. Create a new StaticColumn in your Grid, Set that columns's DataField as "Country"; 2. Populate the Grid from that DataSource; That should work fine and you can then try to identify the problem by comparing this working code and your code. The difference should be in your data column name or types. If non works or you can not find the difference, we will need you to create a sample project that demonstrates the problem so that we can look into it. Thanks
|
|