Hi,I have a Datagridview, wich I want to be binded to a ObjectDataSource.
In code, Atm I got this. A preview would a appricated, I aint asking for code since I wouldnt learn anything from it, an explanation would do the trick I'm assuming
but the gridview is empty, Since i'm new to infragistics, could any1 help me on my way?
<ig:WebDataGrid ID="GridAutorisatieMatrix" runat="server" Height="199px" Width="679px" EnableAjax="False" EnableDataViewState="True" AutoGenerateColumns="False"> <Columns> <ig:BoundDataField DataFieldName="Company" Key="Company" Width="80px"> <Header Text="Username" /> </ig:BoundDataField> <ig:TemplateDataField Key="Algemeen" Width="90px"> <ItemTemplate> <div style="text-align: center;"> <asp:CheckBox runat="server" ID="key_Algemeen" /></div> </ItemTemplate> <HeaderTemplate> <div style="text-align: center;"> <asp:Label ID="Label2" runat="server" Text="Algemeen"></asp:Label> <input type="checkbox" onclick="selectFirstColumn(event);" /> </div> </HeaderTemplate> </ig:TemplateDataField> <ig:TemplateDataField Key="Financieel"> <ItemTemplate> <div style="text-align: center;"> <asp:CheckBox runat="server" ID="key_Financieel" /></div> </ItemTemplate> <HeaderTemplate> <div style="text-align: center;"> <asp:Label ID="Label3" runat="server" Text="Financieel"></asp:Label> <input type="checkbox" onclick="selectFirstColumn(event);" /> </div> </HeaderTemplate> </ig:TemplateDataField> <ig:TemplateDataField Key="Licentie"> <ItemTemplate> <div style="text-align: center;"> <asp:CheckBox runat="server" ID="key_Licentie" /></div> </ItemTemplate> <HeaderTemplate> <div style="text-align: center;"> <asp:Label ID="Label3" runat="server" Text="Licentie"></asp:Label> <input type="checkbox" onclick="selectFirstColumn(event);" /> </div> </HeaderTemplate> </ig:TemplateDataField> <ig:TemplateDataField Key="Applicatie"> <ItemTemplate> <div style="text-align: center;"> <asp:CheckBox runat="server" ID="key_Applicatie" /></div> </ItemTemplate> <HeaderTemplate> <div style="text-align: center;"> <asp:Label ID="Label3" runat="server" Text="Applicatie"></asp:Label> <input type="checkbox" onclick="selectFirstColumn(event);" /> </div> </HeaderTemplate> </ig:TemplateDataField> <ig:TemplateDataField Key="UitDienst"> <ItemTemplate> <div style="text-align: center;"> <asp:CheckBox runat="server" ID="key_UitDienst" /></div> </ItemTemplate> <HeaderTemplate> <div style="text-align: center;"> <asp:Label ID="Label3" runat="server" Text="Uit Dienst"></asp:Label> <input type="checkbox" onclick="selectFirstColumn(event);" /> </div> </HeaderTemplate> </ig:TemplateDataField> </Columns> <Behaviors> <ig:Selection ColumnSelectType="Single" /> <ig:Sorting> </ig:Sorting> </Behaviors> </ig:WebDataGrid><asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetUsersByProfileProperty" TypeName="DotNetNuke.Entities.Users.UserController"> <SelectParameters> <asp:Parameter Name="PortalId" Type="Int32" /> <asp:Parameter Name="propertyName" Type="String" /> <asp:Parameter Name="propertyValue" Type="String" /> <asp:Parameter Name="pageIndex" Type="Int32" /> <asp:Parameter Name="pageSize" Type="Int32" /> <asp:Parameter Name="totalRecords" Type="Int32" Direction="InputOutput" /> </SelectParameters></asp:ObjectDataSource>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load, GridAutorisatieMatrix.DataBinding If Page.IsPostBack = False Then GetData() Else GridAutorisatieMatrix.DataSource = UserController.GetUsersByProfileProperty(PortalId, "Company", Company, 0, 10, 100) GridAutorisatieMatrix.DataBind() End If End Sub Private Sub GetData() Dim userInfo As UserInfo Dim Company As String Dim Result As DataSet userInfo = UserController.GetCurrentUserInfo() If userInfo.UserID = -1 Then End If Company = userInfo.Profile.GetPropertyValue("Company") Me.GridAutorisatieMatrix.DataSource = Result Me.GridAutorisatieMatrix.DataBind() End Sub
You should set Grid's DataSourceID to ObjectDataSource1 and should not set DataSource in the code behind, also you don't need to call DataBind() explicitly.
Hope that helps!
When I do that it says Wrong input string, so that why i'd rather do it with code behind it.
when I do it with a SqlDataSource I do get a filled datagrid, but when doing it with an objectdatasource, its empty
Seems that the ObjectDataSource is not configured properly,
not mather what I do, it keeps saying Object reference not set to an instance of an object.It doesnt even mater wich object I choose to bind..
Are you able to bind the ObjectDataSource with the built-in ASP .Net GridView. If not then it is the ObjectDataSource which is not configured properly.