i am using the following method to assign value to label or textbox:
First i take dropdownlist then i use databound then i assign dropdownlist value to a label or textbox.
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="A" DataTextField="Regisno" DataValueField="Regisno">
</asp:DropDownList>
<asp:AccessDataSource ID="A" runat="server" DataFile="~/App_Data/Database.mdb"
SelectCommand="SELECT [Regisno] FROM [tblsignupv] WHERE ([Email] = ?)">
<SelectParameters>
<asp:SessionParameter Name="Email" SessionField="User" Type="String" />
</SelectParameters>
</asp:AccessDataSource>
I want to know a method to assign value to label or textbox directly from database using c# code
thnx in advance
If your combobox is already filled with data, you can select an item simply by using:
If your values come from a database, then you must use something like :
of course you need to change the “text” and “value” to the columns of your database.