C
Chicagoboy27
I am wondering how to set an object datsource or any data source for a
dropdown list that is a details view. Here is a brief set up. I have a
details view that lists a bunch of information. when a user clicks and
edit button a few of the fields become editable or unhidden in this
example..... There are two types of roles for this system and depending
on which role you are in you have a different data source for the
dropdown list.... Here is what I have so far.
details view Info: Two routes one hidden and one not the hidding will
switch once the use clicks the edit button.
<aspetailsView ID="DetailsView1" Cellpadding="5" runat="server"
AutoGenerateRows="False" DataSourceID="ObjectDataSource3"
Height="50px" Width="250px" GridLines="None" ForeColor="#333333"
Font-Size="80%" >
<Fields>
<asp:TemplateField HeaderText="Route:" SortExpression="route"
HeaderStyle-Width="30%" Visible="true">
<ItemTemplate>
<asp:Label ID="lblRoute" runat="server" Text='<%#
Eval("route")%>'></asp:Label>
</ItemTemplate>
<ItemStyle Wrap="False" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Route:" SortExpression="route"
HeaderStyle-Width="30%" Visible="false">
<ItemTemplate>
<aspropDownList ID="ddlRoute" DataSourceID="ObjectDataSource5"
DataTextField="route" DataValueField="route" Font-Size="98%"
runat="server" SelectedValue='<%# Eval("route")%>' ></aspropDownList>
</ItemTemplate>
<ItemStyle Wrap="False" />
</asp:TemplateField>
</Fields>
</aspetailsView>
Code: I have tried setting the Datasource ID like below but it does not
seem to work....
if (Session["UserIsManager"] == "true")
{
((DropDownList)DetailsView1.FindControl("ddlRoute")).DataSourceID =
ObjectDataSource1.ToString();
}
Any suggestions would be appreciated.. Thanks again.
dropdown list that is a details view. Here is a brief set up. I have a
details view that lists a bunch of information. when a user clicks and
edit button a few of the fields become editable or unhidden in this
example..... There are two types of roles for this system and depending
on which role you are in you have a different data source for the
dropdown list.... Here is what I have so far.
details view Info: Two routes one hidden and one not the hidding will
switch once the use clicks the edit button.
<aspetailsView ID="DetailsView1" Cellpadding="5" runat="server"
AutoGenerateRows="False" DataSourceID="ObjectDataSource3"
Height="50px" Width="250px" GridLines="None" ForeColor="#333333"
Font-Size="80%" >
<Fields>
<asp:TemplateField HeaderText="Route:" SortExpression="route"
HeaderStyle-Width="30%" Visible="true">
<ItemTemplate>
<asp:Label ID="lblRoute" runat="server" Text='<%#
Eval("route")%>'></asp:Label>
</ItemTemplate>
<ItemStyle Wrap="False" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Route:" SortExpression="route"
HeaderStyle-Width="30%" Visible="false">
<ItemTemplate>
<aspropDownList ID="ddlRoute" DataSourceID="ObjectDataSource5"
DataTextField="route" DataValueField="route" Font-Size="98%"
runat="server" SelectedValue='<%# Eval("route")%>' ></aspropDownList>
</ItemTemplate>
<ItemStyle Wrap="False" />
</asp:TemplateField>
</Fields>
</aspetailsView>
Code: I have tried setting the Datasource ID like below but it does not
seem to work....
if (Session["UserIsManager"] == "true")
{
((DropDownList)DetailsView1.FindControl("ddlRoute")).DataSourceID =
ObjectDataSource1.ToString();
}
Any suggestions would be appreciated.. Thanks again.