ASP.NET C# - Dropdown list by using User Control

Speenspap

New Member
I am new to ASP.NETSomeone in this forum helped me how to get the dropdown list work wth user countrol and it is working.In my user control file, VendorListControl.ascx, I have this code below. Please assume that the VendorListControl.ascx.cs works correctly, which is when I select a VendorName, it will fired "ddlVendor_SelectedIndexChanged" to refreshed the "ddlVendorBUList" dropdown list.\[code\]<%@ Control Language="C#" AutoEventWireup="true" CodeFile="VendorListControl.ascx.cs" Inherits="MyNamespace.VendorListControl" %><asp:DropDownList runat="server" ID="ddlVendorList" onselectedindexchanged="ddlVendor_SelectedIndexChanged" AutoPostBack="True" /> <asp:DropDownList runat="server" ID="ddlVendorBUList" AutoPostBack="True" /> <asp:Label runat="server" ID="lblMessage" /> \[/code\]Next, in my CreateNewRecord.aspx page, I have this code to include both dropdown list from user control. And I can see the dropdown lists works properly.\[code\]<%@ Register TagPrefix="uc" TagName="VendorListControl" Src="http://stackoverflow.com/questions/12731786/Controls/VendorListControl.ascx" %>// Some where in the form<tr> <td class="right" width="20%">Vendor Name:</td> <td> <uc:VendorListControl runat="server" /> </td></tr>\[/code\]The problem is related to the ID of those two dropdown lists. When I attemp to do the insert record, it seems not to detect the ID for "ddlVendorList" and "ddlVendorBUList" come from user control ascx page. Error " The name 'ddlVendorList' does not exist in the current context"\[code\]ExecuteInsert(ddlVendorList.SelectedItem.Text, ddlVendorBUList.SelectedItem.Text, MDFAmount.Text, StartDate.Text, EndDate.Text, VendorQuarter.Text, MDFName.Text, MDFSummary.Text, Status.SelectedItem.Text, CreatedBy.Value );Response.Write("<b>Record was successfully added!</b>");\[/code\]I know I am new to ASP.NET, so please help.
 
Back
Top