-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: blr-ms-jobs
Message 1 in Discussion

How do I bind a datasource to a <asp:Dropdownlist ID="mydropdown" ...> declared 
within an <asp:repeater ...> ?
When I try 

        mydropdown.DataSource = hshDepartment;
        mydropdown.DataKeyField = hshDepartment..Keys;
        mydropdown.DataValueField = hsbDepartment.Values;
        mydropdown.DataBind();

The compiler is not accepting the assignment. Says can't find "mydropdown"

Following is the stripped down version of the Page for reference.

<%@ Page Language="C#" %>
<%@ import Namespace="System" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Collections" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
 runat="server">
    protected void Page_Load(Object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindMyData();
        }
    }
    void BindMyData()
    {
        //Connect to Database and get the data
        ...
        PublishArticles.DataSource = dr;
        PublishArticles.DataBind();

        Hashtable hshDepartment = new Hashtable();
        hshDepartment.Add(...);
        // Creation of Hashtable here
        ...     
        mydropdown.DataSource = hshDepartment;
        mydropdown.DataKeyField = hshDepartment..Keys;
        mydropdown.DataValueField = hsbDepartment.Values;
        mydropdown.DataBind();
    }
...
<body>
...
<
<asp:Repeater ID="PublishArticles" Runat="Server">
    <ItemTemplate>
        ...
        // Display of Items retrieved from DB goes here
        <asp:DropDownList ID="mydropdown" runat="Server" />
    </ItemTemplate>    
</asp:Repeater>
...
</body>
</html>


-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDOTNET/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to