0

I have a drop down list that displays all the titles from my table in the database. This works fine, however, i want it to display the title of whichever person the query has searched for.

For example, the list has all the titles in, i have clicked on my link which shows me the details for a person, and i want the value that is shown in the drop down list to be the title of the person the query has searched for, and then listing the list of titles again after this value.

How can I do this?

<asp:DropDownList ID="ddlTitle" runat="server"  DataSourceID="obdsGetTitleForDropDown" DataTextField="Title" 
DataValueField="Title_RefNo" Width="100%">
</asp:DropDownList>

Thanks

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by rohand
0

You can do it programmatically with linq if you know how to use that.
Thats my favorite way of making customized queries on different events.

A code example if you know visual basic.net:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Using myEnt As New PicturesEntities()
            Dim tagsN = From tag In myEnt.Tags
                        Select tag.TagName

            TagLB.DataSource = tagsN
            TagLB.DataSourceID = ""
            TagLB.DataBind()
        End Using
    End Sub
0

Yes you can do it by below way..

//once you have bind your drop down, define object of ListItem.
ListItem objListItem = DropDownList1.Items.FindByValue("Title_RefNo value retrieved from query for particular person ");
if (objListItem != null)
{
    DopDownList1.SelectedValue = objListItem .Value;
    objListItem .Selected = true;
}

that's all...

I have a drop down list that displays all the titles from my table in the database. This works fine, however, i want it to display the title of whichever person the query has searched for.

For example, the list has all the titles in, i have clicked on my link which shows me the details for a person, and i want the value that is shown in the drop down list to be the title of the person the query has searched for, and then listing the list of titles again after this value.

How can I do this?

<asp:DropDownList ID="ddlTitle" runat="server"  DataSourceID="obdsGetTitleForDropDown" DataTextField="Title" 
DataValueField="Title_RefNo" Width="100%">
</asp:DropDownList>

Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.