473,473 Members | 2,179 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

method to bind ListBox, DropDownList, RadioButtonList

I tried to create a simple method to bind 3 kind of control

private void SimpleBinding(ListControl lc, string tblName, string txtField,
string valField){
SqlDataReader dr = ....
//... get value from database

lc.DataTextField = txtField;
lc.DataValueField = valField;
lc.DataBind();
}
-- call method:
SimpleBinding(DropDownList1,"Employee","FullName", "EmployeeID");

There is no error but the value not bind to the control.

Did I do something wrong?
How to create a method to handle this sort of binding?

Many thanks,
Kids
Nov 17 '05 #1
1 1972
Sorry I forgot to put .. :(
lc.DataSource = dr;

"kids_pro" <ki******@yahoo.com> wrote in message
news:uV**************@TK2MSFTNGP15.phx.gbl...
I tried to create a simple method to bind 3 kind of control

private void SimpleBinding(ListControl lc, string tblName, string
txtField, string valField){
SqlDataReader dr = ....
//... get value from database

lc.DataTextField = txtField;
lc.DataValueField = valField;
lc.DataBind();
}
-- call method:
SimpleBinding(DropDownList1,"Employee","FullName", "EmployeeID");

There is no error but the value not bind to the control.

Did I do something wrong?
How to create a method to handle this sort of binding?

Many thanks,
Kids

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: bill yeager | last post by:
Duray, it helps in regards to knowing how to get the items that were selected in the lisbox, but I'm going in reverse --- after I get the items from the db that were selected, I'd like to be able...
0
by: Victor | last post by:
Hi there, I have a question: I use a listbox (server sided) and a radiobuttonlist(server sided, 10 items)on my form.aspx. What i want to do is the following. If I select a value from the...
2
by: Serg | last post by:
Hello, I need to set the selection in the RadioButtonList according to the value of SelectedValue in the underlying dataset - please suggest. The code is below. Thank you. <asp:TemplateColumn>...
5
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all...
2
by: COHENMARVIN | last post by:
I'm leafing through a big book on asp.net, and I don't see any way to the following: 1. bind values and text to a dropdown 2. Also make the first line of the dropdown say something different. For...
1
by: mr2_93 | last post by:
Hi All, I am new to ASP.NET and I am looking for help with the dropdownlist data control. I wonder if someone could show me how to past the SelectedValue of a data-bind dropdownlist to...
1
by: Patrik Zdarsa | last post by:
Hi, I'm try VS 2005 and need UPDATE database record in viewform, all working when every filed is type TextBox (html INPUT) but I need change one TextBox to Listbox or dropdownlist and read data...
3
by: sck10 | last post by:
Hello, I am trying to bind an arraylist to a FormView DropDownList control in the PreRender state. The error that I get is the following: Databinding methods such as Eval(), XPath(), and...
0
by: frankiefrank | last post by:
Hello, I have an aspx page with a RadioButtonList that has two Items, and a "ComboBox" (DropDownList) that I want to populate based on the selection in the RadioButtonList. The first...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.