Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Setting DropDown datasource

Reply
Thread Tools

Setting DropDown datasource

 
 
David C
Guest
Posts: n/a
 
      06-19-2008
I have a GridView with a DropDownList control that is tied to an
SqlDataSource. It pulls from a table/view of staff people and is a
data-bound control linked to an ID column in the GridView data source. I
want to be able to show only the active staff people in the DropDownList.
However, if I edit an old record with an ID tied to an inactive staff member
then the asp.net page throws an exception.

How do I best get around this so that I can show only the current ID staff
person and all the other "active" staff people? And where is the best place
to change my data source? I only care if I am editing the row. Below is my
data source SQL. Thanks.

<asp:SqlDataSource ID="SqlvwStaffPick" runat="server"
ConnectionString="<%$ ConnectionStrings:FiledataConnectionString %>"
SelectCommand="SELECT [PersonID], [Person] FROM [vw_StaffPick]
ORDER BY [Person]">
</asp:SqlDataSource>

David


 
Reply With Quote
 
 
 
 
Mike L
Guest
Posts: n/a
 
      06-19-2008
Does your SQL statement contain the active flag? in your SQL?

Also you will need the find.control method when trying to use the dropdown
in the gridview container. I hope this helps.

"David C" wrote:

> I have a GridView with a DropDownList control that is tied to an
> SqlDataSource. It pulls from a table/view of staff people and is a
> data-bound control linked to an ID column in the GridView data source. I
> want to be able to show only the active staff people in the DropDownList.
> However, if I edit an old record with an ID tied to an inactive staff member
> then the asp.net page throws an exception.
>
> How do I best get around this so that I can show only the current ID staff
> person and all the other "active" staff people? And where is the best place
> to change my data source? I only care if I am editing the row. Below is my
> data source SQL. Thanks.
>
> <asp:SqlDataSource ID="SqlvwStaffPick" runat="server"
> ConnectionString="<%$ ConnectionStrings:FiledataConnectionString %>"
> SelectCommand="SELECT [PersonID], [Person] FROM [vw_StaffPick]
> ORDER BY [Person]">
> </asp:SqlDataSource>
>
> David
>
>
>

 
Reply With Quote
 
 
 
 
David C
Guest
Posts: n/a
 
      06-20-2008
Yes, but my biggest concern is where can I reset the datasource so that I do
not get an exception? I want to be able to get all "active" as well as the
ID currently in the underlying datasource, even if that person is not
currently active. For example
SELECT [PersonID], [Person] FROM [vw_StaffPick] WHERE Active = 1 OR PersonID
= <controlID> ORDER BY [Person]

Thanks.
David

"Mike L" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Does your SQL statement contain the active flag? in your SQL?
>
> Also you will need the find.control method when trying to use the dropdown
> in the gridview container. I hope this helps.
>
> "David C" wrote:
>
>> I have a GridView with a DropDownList control that is tied to an
>> SqlDataSource. It pulls from a table/view of staff people and is a
>> data-bound control linked to an ID column in the GridView data source. I
>> want to be able to show only the active staff people in the DropDownList.
>> However, if I edit an old record with an ID tied to an inactive staff
>> member
>> then the asp.net page throws an exception.
>>
>> How do I best get around this so that I can show only the current ID
>> staff
>> person and all the other "active" staff people? And where is the best
>> place
>> to change my data source? I only care if I am editing the row. Below is
>> my
>> data source SQL. Thanks.
>>
>> <asp:SqlDataSource ID="SqlvwStaffPick" runat="server"
>> ConnectionString="<%$ ConnectionStrings:FiledataConnectionString %>"
>> SelectCommand="SELECT [PersonID], [Person] FROM
>> [vw_StaffPick]
>> ORDER BY [Person]">
>> </asp:SqlDataSource>
>>
>> David
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can not add to/modify dropdown list after datasource has been load =?Utf-8?B?TWVyZGFhZA==?= ASP .Net 5 11-07-2006 02:32 PM
Getting value of field in dropdown datasource within Formview =?Utf-8?B?VEpIZXJtYW4=?= ASP .Net 0 06-19-2006 06:18 PM
datasource values and dropdown list =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= ASP .Net 0 05-06-2006 03:54 PM
Can not add/modify dropdown liat after datasource has been loaded =?Utf-8?B?TWVyZGFhZA==?= ASP .Net 0 10-20-2004 08:47 PM
Datasource in a dropdown list Paul ASP .Net 2 04-27-2004 08:16 PM



Advertisments