473,881 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

databind to datarow

Hi,

I have a DataRow that I want to bind to a dropdown list. I have 2 columns
(TypeName, TypeValue). When do

ddlNewAttribute .DataSource = drAttrValues;
ddlNewAttribute .DataBind();

How do I go about binding to a specific column (TypeValue)?

Right now I'm getting [System.Data.Dat aRow] for the values.

Thanks
Maz.
Nov 19 '05 #1
4 1891
Maziar Aflatoun <ma***@rogers.c om> ha scritto:
Hi,

I have a DataRow that I want to bind to a dropdown list. I have 2
columns (TypeName, TypeValue). When do

ddlNewAttribute .DataSource = drAttrValues;
ddlNewAttribute .DataBind();

How do I go about binding to a specific column (TypeValue)?

Right now I'm getting [System.Data.Dat aRow] for the values.

Thanks
Maz.


ddlNewAttribute .DataTextValue= "TypeName"
ddlNewAttribute .DataFieldValue ="TypeValue"
ddlNewAttribute .DataSource = drAttrValues;
ddlNewAttribute .DataBind();

--
AZ [Microsoft - .NET MVP]
Mia Home page: http://ciclismo.sitiasp.it
Asp.Net community: http://www.aspitalia.com
Il mio blog: http://blogs.aspitalia.com/az
Nov 19 '05 #2
Remember DropDownList fills listItems with the datasource when bound.
So what you can do is for instance:

ddlNewAttribute .datasource=Dat aSet;
ddlNewAttribute .datamember="ta bleReferance"
ddlNewAttribute .DataBind();
// Selects the row and adds it to ListItem collection
ddlNewAttribute .Items.Add(new ListItem("TypeN ame, "TypeValue" ));
// To set the index of the Item use the insert method.
ddlNewAttribute .Items.insert(i nt index, new
ListItem("TypeN ame","TypeValue "));
/*If your trying to bind the DropDownList to a templated control, rather in
the EditItemTemplat e, the DropDownList does not exist until the user selects
edit so the binding process is different. You'll have to create a method
that calls the data in the codebehind and and stuff it (I prefer DataView
object) into an object and set the datasource at runtime.
I'd show you but I'm to lazy right now :-). */

I am Sam-
"Maziar Aflatoun" <ma***@rogers.c om> wrote in message
news:jO******** ************@ro gers.com...
Hi,

I have a DataRow that I want to bind to a dropdown list. I have 2 columns
(TypeName, TypeValue). When do

ddlNewAttribute .DataSource = drAttrValues;
ddlNewAttribute .DataBind();

How do I go about binding to a specific column (TypeValue)?

Right now I'm getting [System.Data.Dat aRow] for the values.

Thanks
Maz.


Nov 19 '05 #3
Remember DropDownList fills listItems with the datasource when bound.
So what you can do is for instance:

ddlNewAttribute .datasource=Dat aSet;
ddlNewAttribute .datamember="ta bleReferance"
ddlNewAttribute .DataBind();
// Selects the row and adds it to ListItem collection
ddlNewAttribute .Items.Add(new ListItem("TypeN ame, "TypeValue" ));
// To set the index of the Item use the insert method.
ddlNewAttribute .Items.insert(i nt index, new
ListItem("TypeN ame","TypeValue "));
/*If your trying to bind the DropDownList to a templated control, rather in
the EditItemTemplat e, the DropDownList does not exist until the user selects
edit so the binding process is different. You'll have to create a method
that calls the data in the codebehind and and stuff it (I prefer DataView
object) into an object and set the datasource at runtime.
I'd show you but I'm to lazy right now :-). */

I am Sam-
"Maziar Aflatoun" <ma***@rogers.c om> wrote in message
news:jO******** ************@ro gers.com...
Hi,

I have a DataRow that I want to bind to a dropdown list. I have 2 columns
(TypeName, TypeValue). When do

ddlNewAttribute .DataSource = drAttrValues;
ddlNewAttribute .DataBind();

How do I go about binding to a specific column (TypeValue)?

Right now I'm getting [System.Data.Dat aRow] for the values.

Thanks
Maz.

Nov 19 '05 #4
Remember DropDownList fills listItems with the datasource when bound.
So what you can do is for instance:

ddlNewAttribute .datasource=Dat aSet;
ddlNewAttribute .datamember="ta bleReferance"
ddlNewAttribute .DataBind();
// Selects the row and adds it to ListItem collection
ddlNewAttribute .Items.Add(new ListItem("TypeN ame, "TypeValue" ));
// To set the index of the Item use the insert method.
ddlNewAttribute .Items.insert(i nt index, new
ListItem("TypeN ame","TypeValue "));
/*If your trying to bind the DropDownList to a templated control, rather in
the EditItemTemplat e, the DropDownList does not exist until the user selects
edit so the binding process is different. You'll have to create a method
that calls the data in the codebehind and and stuff it (I prefer DataView
object) into an object and set the datasource at runtime.
I'd show you but I'm to lazy right now :-). */

I am Sam-
"Maziar Aflatoun" <ma***@rogers.c om> wrote in message
news:jO******** ************@ro gers.com...
Hi,

I have a DataRow that I want to bind to a dropdown list. I have 2 columns
(TypeName, TypeValue). When do

ddlNewAttribute .DataSource = drAttrValues;
ddlNewAttribute .DataBind();

How do I go about binding to a specific column (TypeValue)?

Right now I'm getting [System.Data.Dat aRow] for the values.

Thanks
Maz.


Nov 19 '05 #5

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

Similar topics

4
2922
by: Michael Carr | last post by:
I have a function that populates a class with values from a database. I'd like to pass into the function either a SqlDataReader or a DataRow, depending on which mechanism I'm using to retrieve data from the database. However, the two classes don't appear to have any common interfaces that would allow me to enumerate the fields. Yet, when you databind you can pass either of these classes (as well as many others) and .NET somehow knows how...
3
12027
by: Marty McDonald | last post by:
I have <asp:Table... </asp:Table> on my webform. In codebehind, I populate a DataTable whose data should appear in the asp:Table. I created my own code to populate the asp:Table with the DataTable, then I discovered the asp:Table has a DataBind method. But the method takes no args and so I'm confused how to use it. Is there a link to see how DataBind works for asp:Table? Should I just use my own code anyway? Thanks... Here's my...
4
2017
by: CaptRR | last post by:
I think this is the right group to post to, so here goes. My problem is this, I cannot update the datarow to save my life. Been on this for 2 days now, and still am no closer to figuring it out than I was before. I'm basicly taking date from some text boxes, trying to put them into a datarow and using that datarow to update the database, but its not working. The btn_update is where I am sending the information back to the addclient...
2
6130
by: Ali M | last post by:
Hi, I am creating a TextBox dynamically at runtime within a Panel, and I want to bind its Text property to a DataColumn in a DataRow. What is the correct method for doing this... The following code does not populate the textbox at all... Thanks in advance... Ali
1
2204
by: guoqi zheng | last post by:
Dear sir, I have a textbox inside a repeart control, autopostback set to true for that textbox. When the value of this textbox changes, I need to access current row and update database. Repeater is bind to a dataset. VS.NET generate a below event on double click. However, I did not see any way to access current row. Public Sub TxtQuantity_TextChanged(ByVal sender As Object, ByVal e As System.
17
4664
by: Jan Nielsen | last post by:
Hi I would like to databind a Picturebox to a SQL Server. I have a typed Dataset "DSBoernekirken1" It has a table named "tpersoner" with a column "Photo" I of course would like to bind the image directly to tpersoner.photo using Properties (like I do with text fields), but this does not seem to be possible. Then I searched some news groups and Knowledgebase and found the following
1
2947
by: Craig | last post by:
This is killing me, I've been trying to figure this out for 2 days. When I click on the linkbutton, it executes the GetData(int) method to set the DataSource. The FAILURE is when it tries to call databind (sender.DataBind(); in NeedList_ItemCommand method). The error message is at the bottom of this message (System.NullReferenceException) Can anyone else see anything wrong with this? (I've included all relevant code, stored...
6
1642
by: JIM.H. | last post by:
Hello I have; DataRow dr= dataSet11.myTable.NewRow(); And I am filling the fields of this datarow. Now I need to create a copy of this row as drCopy and change a few fields and add both to the dataset, how can I do this? Thanks,
4
2455
by: Luqman | last post by:
I have created a form using Data Sources in VB.Net 2005, and Binding Navigator, even I did not write a single line of code and data is displaying, saving, deleting perfectly with the click of buttons on Binding Navigator. Now, what I want, that if the user clicks on the Save Button of Binding Navigator, one field of that table should be saved with Current Date and Time. Do I need to use BuyerBindingSource, BuyerTableAdapter or dsBuyer...
0
9926
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
11096
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10716
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10812
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10400
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7108
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5780
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.