Hi, I am new to using Object Data Source and am curious as far as its cusomizing limits. I would like to use the object Data Source in Gridview and am wondering the following things. I am using VB.NET in the code behind
1) Can the bound field names in the Gridview be changed at runtime / dynamically? for ex
<Columns>
<asp:BoundField DataField="ProductName"
HeaderText="ProductName" SortExpression="ProductNam
e" />
<asp:BoundField DataField="CategoryName" HeaderText="Category"
ReadOnly="True"
</Columns>
Can I change the Bound field Data field in runtime since I am pulling data from different tables so the field names would be different, Is it possible to do this?
2) I want to do the same for a Dropdown template column. I want to be able to pull the lists of different types of products from different tables as well . Because from what I have seen If I use Edit Item Template and a seperate object Data source for the Drop down I have to assign the DataValue and text fields in the Data Source configuration Wizard. Can I modify for e.g the following code in Code behind in VB.NET as well to give the label and the drop down different field names to bind to?
<asp:TemplateField HeaderText="Category" SortExpression="CategoryNa
me">
<EditItemTemplate>
<asp:DropDownList ID="Categories" runat="server"
DataSourceID="CategoriesDa
taSource"
DataTextField="CategoryNam
e" DataValueField="CategoryID
">
</asp:DropDownList>
<asp:ObjectDataSource ID="CategoriesDataSource" runat="server"
OldValuesParameterFormatSt
ring="orig
inal_{0}"
SelectMethod="GetCategorie
s" TypeName="CategoriesBLL">
</asp:ObjectDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server"
Text='<%# Bind("CategoryName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Thanks to anyone who can help me out with this. Please provide a sample of the code behind if this is possible. Your help's really appreciated
Start Free Trial