473,325 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Dynamicaly populate object source for dropdown in Details view

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.

<asp:DetailsView 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>
<asp:DropDownList ID="ddlRoute" DataSourceID="ObjectDataSource5"
DataTextField="route" DataValueField="route" Font-Size="98%"
runat="server" SelectedValue='<%# Eval("route")%>' ></asp:DropDownList>
</ItemTemplate>
<ItemStyle Wrap="False" />
</asp:TemplateField>

</Fields>
</asp:DetailsView>
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.

Oct 23 '06 #1
0 1382

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not...
0
by: Nithin | last post by:
My code as an txt attachment. I have 2 drop down list boxes that on selection populate text boxes from my database table. I am able to display the correct values in these text boxes. I have 2...
4
by: nicholas | last post by:
I tried to set the ID of a radiobuttonlist dynamicaly like this: <asp:RadioButtonList id="<%# DataBinder.Eval(Container.DataItem, "optionnameFR") %>" runat="server" ></asp:RadioButtonList> ...
3
by: anand basha | last post by:
Hi, How to set values dynamicaly to dropdown listbox while clicking the button *** Sent via Developersdex http://www.developersdex.com ***
3
by: Laura K | last post by:
I have been trying to figure this one out. I really need help. I have a relationship between two tables - product and colors. I have a repeater listing the products and then each product has a...
13
by: Selesti | last post by:
I have written an Access database that our department uses to store and analyze information on particular jobs. Because our company runs on an enormous SQL DB, I thought it would save some time if...
0
by: pintu | last post by:
Hello everybody...Any one plz help in solving my problem mentioned below.. I am creating an application in asp.net 2.0.I want 2 dropdowns i.e customer and branch to be present inside detailsview...
0
by: Kay O'Keeffe | last post by:
Hello, I have written my own custom control and I want one of its properties to display as a dropdown list when clicked, so the user can select from the list, it would be similar to the asp...
8
by: Wingot | last post by:
Hey, I have a program I am trying to write using Visual C#, SQL Server 2005/2008, and Visual Studio 2008, and one part of it includes a Schema called Client. Inside this schema, three tables...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.