.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

how to fill user control(.ascx) (Dropdown from Database)

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :ASP.Net

i am created a user control(.ascx)

<span><asp:DropDownList ID="Drop_DocType" runat="server"  DataTextField="DOCTYPE"DataValueField="DOCTYPE"/></span>

  how to fill it rom database and where i put soure code

View Complete Post

More Related Resource Links

how to create dropdownlist user control(acsx) and fill from database


how to create dropdownlist user control(acsx) and fill from database

How to fill out a form as another user , while using profiles database


I have created an InfoPath 2007 form. It works great.. I have 5 data connections to sharepoint lists and profile's database. The form displays public data (profile database) about the user, such as name, manager.. etc.

What I would like to do is have an option on the form that says " If you are not this person , click here" , manually type the persons last name , and bring up their information.

Basically , there are some people who will have someone else fill the form out for them. But I don't want them to be giving out their username and password to the system.

I want the ability to fill out a form as another user without logging off sharepoint. 

Referencing ConfiguratingSettings.AppSettings in a ASCX user control?

Hi there,I'm trying to reference a string from the web.config file from a ASCX user control, but I get the error message: [b]Compiler Error Message: BC30203: Identifier expected.My code in the user control file is as follows:<div id="header"><h1><%= Server.HtmlEncode(Convert.ToString(ConfigurationSettings.AppSettings["Web_Title"])) %></h1></div>Do I need to import any namespaces? Hopefully someone can help!Thanks

how to implement user rating using ajax rating control from database?

Hi,I'm beginner to ajax. I've a database table having fields rating and item id.I've to display star rating using  ajax rating control for the corresponding item id.How can i do this?  

How to Access Parent Page (.aspx) control (IDs) from its child User Control (.ascx)

I have a parent .aspx page that has a asp:panel control in it, and this parent .aspx is also referencing a user control that I registered in that .aspx. Lets just call it usercontrolA.ascx for this post.The user control has a radiobuttonlist itself.Based on a selection from the radiotbuttonlist in the user control, I want to be able to hide the asp:panel in my .aspx (parent) but unfortunately I cant' get it to work:parentPanel.visible = true;  <<< I trried this in usercontrolA.ascx.csBut the user control doesn't know about the panel in the parent .aspxSo do I need to expose that somehow from the parent so that I can access it from the code behind of the child .ascx?  How?

User Data from database...can't fill ddl on PageLoad because of DataBound

I have a database where a user inputs data to multiple databound drop down listboxes.  That's saved to my aspnet database.  Then when the page loads again, I want to select the ddls items that the user selected as stored in the database to these databound ddls.  But it doesn't work, because on pageload, they haven't been databound yet.What's the best way to do this?  Do I need to run a SELECT statement for each and every ddl on it's databound event???

MS SQL Server: Disconnect Users From Database - Kill User Session

If you ever wanted to restore your database from a SQL backup file (.bak), but there are still users connected to your database, the backup operation will fail causing the error: Exclusive access could not be obtained because the database is in use.

Choosing Between a User Control or Web Part for SharePoint

SharePoint will only display Web Parts on a page. However, there are publicly available shims that allow you to write user controls and have them be displayed as a Web Part. From SharePoint's point of view, the shim is a Web Part. From the point of view of the user control, the shim is simply a control in .NET that is including the user control

Building Re-Usable ASP.NET User Control and Page Libraries with VS 2008


I am having problems with a user control. I want my solution to have a separate project for holding my user controls.

The main project can get a reference to this user control project and can import this user control dll into my main project. 

Thanks in advance,

Dheeraj Mittal


Multiple Instances of User Control


I have a user control that I place on a page severl times.  When I make a selection on a ddl in one one control the SelectedIndexChanged event fires for all the control on the page for that ddl.  So I get duplication of an insert that I do.  Is there a way to make sure these events are isolated so this doesn't happen.


how to get an array of all the asp.net textbox control inside create user wizard control?



How can I get all the textboxes inside a create user wizard control using getElementsByTagName().

Below is my JQuery code:

<script type="text/javascript">
        function addLoadEvent(func) {
            var oldonload = window.onload;
            if (typeof window.onload != 'function') {
                window.onload = func;
            } else {
                window.onload = function() {

        function prepareInputsForHints() {
            var inputs = document.getElementsByTagName("asp:TextBox");
            for (var i = 0; i < inputs.length; i++) {
                inputs[i].onfocus = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
                inputs[i].onblur = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "none";



<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

Linq - add data to database then email user the details


Hi all

I'm not sure how to structure the code for this but what I want to do is be able to add data to a database, and once this has completed successfully, then email the user to say the details have been added successfully to the database.

I need to:

1. Check that the relevant data has been added into the database then

2. Email the details of the relevant data when completed. 


Thanks in advance for your help,




Persist data in a dynamically populated ListBox in a user control


Hi All,

I am trying to persist data in a dynamically populated ListBox in a user control. Here are the details

I have a user control which contains a a listBox and button. On Page_Load of user control I am populating the ListBox control with some values. On Click of button, I am trying to fetch the values which I have selected in ListBox. Though this seems very simple and straight forward I am unable to fetch values.

My Page_Load Function

void Page_Load(object sender, EventArgs e)










My Click Function

Protected Void Button1_Click(object sender, EventArgs e)


       string strValue = listBox.SelectedValue



I have placed brake point at Page_Load and on click function, I am seeing that the moment the breakpoin

Category attribute of user control property does not work correctly in categories tab.



I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Category("Styles"), DefaultValue(""), Description("The value for formating something.")]
public String MyFormatProperty
set { /* the code for set */; }
get { /* the code for get */; }

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

Thanks, S.

OnItemCommand not firing in Templated User Control


I have a templated user control with single instance template attribute. It works great for everything except the following scenario:


    <asp:UpdatePanel ID="upDirectoryBrowser" runat="server">
        <asp:AsyncPostBackTrigger ControlID="fsBrowser" EventName="FolderSelected" />
        <asp:AsyncPostBackTrigger ControlID="flsBrowser" EventName="FileSelected" />
        <asp:AsyncPostBackTrigger ControlID="flsBrowser" EventName="LinkSelected" />
        <table width="100%">
                <td style="width: 230px;">                        
                    <ntc:FolderSelector ID="fsBrowser" runat="server" OnFolderSelected="fsBrowser_FolderSelected"
                    OnControlException="fsBrowser_ControlException"  /> 
                    <ntc:FileSelector ID="flsBrowser" runat="server" OnFileSelected="flsBrowser_FileSelected"
                    OnControlException="fsBrowser_ControlException" O

"Type ASP.x is not defined" error for dynamic user control when publishing updateable


I have a user control (ContainerCtrl) which programmatically instantiates another user control (SimpleCtrl) in OnLoad. It builds and runs fine, but when I publish it I get the error "error BC30002: Type 'ASP.SimpleCtrl' is not defined." (If I publish without the "updateable" option there's no error, but I need the site to be updateable.)

I assume this has to do with the particulars of how the assembly(ies) are built for the different compiler options. My question is, how can I get it to work properly for "updateable" publishing?

VS 2008 / .NET 3.5 sp1

The code follows (web.config is the default from Visual Studio).

Many thanks, Dave


<%@ Control Language="VB" ClassName="SimpleCtrl" CodeFile="SimpleCtrl.ascx.vb" Inherits="_SimpleCtrl" %>

    Simple control


Partial Class _SimpleCtrl
    Inherits UserControl

    'Nothing to see here.

End Class


<%@ Control Language="VB" CodeFile="ContainerCtrl.ascx.vb" Inherits="_ContainerCtrl"

Least Privilege: Teach Your Apps To Play Nicely With Windows Vista User Account Control


User Account Control in Windows Vista keeps the OS safe from intentional and accidental configuration changes.

Chris Corio

MSDN Magazine January 2007

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend