Hello,
When i try to bind a list to a grid, the grid does not get poplulated.
When i do this with the default gridview it gets populated.
Below is the code used, can you tell me what to change to get it working ?
this is the aspx page code
Code: HTML/ASPX
<table class="style1">
<tr>
<td class="style2">
<asp:Label ID="Label1" runat="server" Text="Campus"></asp:Label>
</td>
<td>
<asp:DropDownList ID="LstCampussen" runat="server" Width="150px">
</asp:DropDownList>
</td>
</tr>
</table>
<br />
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
<br />
<eo:Grid ID="Grid1" runat="server" BorderColor="Black" BorderWidth="1px"
ColumnHeaderAscImage="00050403" ColumnHeaderDescImage="00050404"
ColumnHeaderDividerImage="00050402" ColumnHeaderDividerOffset="6"
ColumnHeaderHeight="18" FixedColumnCount="1" Font-Bold="False"
Font-Italic="False" Font-Names="Verdana" Font-Overline="False" Font-Size="9pt"
Font-Strikeout="False" Font-Underline="False" GridLineColor="240, 240, 240"
GridLines="Both" Height="200px" ItemHeight="18" Width="647px">
<ItemStyles>
<eo:GridItemStyleSet>
<ItemStyle CssText="background-color: white" />
<CellStyle CssText="padding-left:8px;padding-top:2px; color:#black;white-space:nowrap;" />
</eo:GridItemStyleSet>
</ItemStyles>
<ColumnHeaderStyle CssText="background-image:url('00050401');padding-left:8px;padding-top:2px;" />
<Columns>
<eo:RowNumberColumn>
</eo:RowNumberColumn>
<eo:StaticColumn HeaderText="Header">
</eo:StaticColumn>
<eo:StaticColumn HeaderText="Header">
</eo:StaticColumn>
</Columns>
<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">
<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" />
<TitleStyle CssText="background-color:#9ebef5;font-family:Tahoma;font-size:12px;padding-bottom:2px;padding-left:6px;padding-right:6px;padding-top:2px;" />
<TitleArrowStyle CssText="cursor:hand" />
<MonthStyle CssText="font-family: tahoma; font-size: 12px; margin-left: 14px; cursor: hand; margin-right: 14px" />
<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" />
<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" />
<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" />
<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" />
</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;" />
</eo:Grid>
this is the vb code
Code: Visual Basic.NET
Imports System.Data.SqlClient
Partial Class BeheerMaterialen
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object,
ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
HaalGegevensUitDatabase()
VulGrid()
End If
End Sub
Protected Sub HaalGegevensUitDatabase()
Dim campussen As List(Of Campus) = CampusDB.GetCampusList()
LstCampussen.DataValueField = "id"
LstCampussen.DataTextField = "Naam"
LstCampussen.DataSource = campussen
LstCampussen.DataBind()
End Sub
Protected Sub LstCampussen_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles LstCampussen.SelectedIndexChanged
VulGrid()
End Sub
Protected Sub VulGrid()
Dim Materiaallijst As List(Of Materiaal) = MateriaalDB.GetAlgemeenMateriaalList(LstCampussen.SelectedValue)
Grid1.DataSource = Materiaallijst
Grid1.DataBind()
GridView1.DataSource = Materiaallijst
GridView1.DataBind()
End Sub
Public Shared Function GetAlgemeenMateriaalList(ByVal campus As Integer) As List(Of Materiaal)
Dim MateriaalList As New List(Of Materiaal)
Dim Connection As SqlConnection = ToepassingDB.GetSqlConnection
Dim selectStatement As String = "select * from XIOS_MaterialenAlgemeen where Campus = @Campus"
Dim selectCommand As New SqlCommand(selectStatement, Connection)
selectCommand.Parameters.Clear()
selectCommand.Parameters.AddWithValue("@Campus", campus)
Try
Connection.Open()
Dim reader As SqlDataReader = selectCommand.ExecuteReader()
While reader.Read
Dim NewMateriaal As New Materiaal
NewMateriaal.ProductID = CInt(reader("id"))
NewMateriaal.Name = reader("Omschrijving").ToString.Trim
MateriaalList.Add(NewMateriaal)
End While
Catch ex As SqlException
Throw ex
Finally
Connection.Close()
End Try
Return MateriaalList
End Function
End Class