populating the dropdown list with the values from the data base, Failing near adding the values todropdown

Here is My code'


&nbsp;<asp:DropDownList ID="ddlkeyword" runat="server" Width="204px" >










private void fillddlkeyword()


string StrSql = "Select distinct(formName)as formName from tbl_form";

oDB.RunDBQuery(StrSql, out oRS);

DataTable dt = new DataTable();


if (oRS.HasRows)


while (oRS.Read())


DataRow dr = dt.NewRow();

dr["Form"] = oRS["formName"].ToString();


 // I can see the data here but When I bind it I am just seeing Data.//ddlkeyword.DataTextField = dr["Form"].ToString();






ddlkeyword.DataTextField = dt.Rows[0].ToString();

ddlkeyword.DataSource = dt;








If I include ddlkeyword.DataTextField = dr["Form"].ToString(); with out comments its failing at the last row saying it could n't find the last row data ex" BUilder "

Help Me,


1/13/2009 9:24:16 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 52
Get it on Google Play
Get it on Apple App Store

I got it Fixed , I added the Data text field and data value Field

<td style="width: 100px">

&nbsp;<asp:DropDownList ID="ddlkeyword" runat="server" Width="204px" DataTextField="Form" DataValueField="Form">



1/13/2009 9:30:31 PM

Similar Artilces:

Populate a Dropdown List based on the value of another Dropdown List
 Hi ALL,    I have two Dropdown List.I need to Populate second Dropdown List based on the value of first Dropdown List.I am n't using Update Panel.Pls suggest me RegardsSri ASP.NET AJAX Cascading DropdownDarrell Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you!   just populate second dropdown in SelectedIndexChanged event of the first dropdown. Muhammad ShoaibSoftware Engineer,Lahore, Pakistanwww.heartofpakistan.com (U/C)--------------------------------Mark it as ANSWER if it Helps U   Check out this link with co...

Populate dropdown list based on selected value in another dropdown list
I have a datagrid (grdCar) that contains two dropdown listboxes (ddlCarManf and ddlCar). When the user clicks the "Edit" link and places the grid into edit mode, they select a value in ddlCarManf. Based on the selected value in ddlCarManf, I need to then populate ddlCar with a list of cars for which the selected manufacturer makes (I'm using ddlCarManf.SelectedValue to query the database).  I bind my datagrid in the page_load event as: If Not Page.IsPostBack Then    BindGrid() End If Here is my control (ddlCarManf) as is appears within grdCar in ...

Drop down list in Form view returns error when value in bound field (data binding
I get the following error when I click edit to edit the details in the web form:'ddlUserRestrictionType' has a SelectedValue which is invalid because it does not exist in the list of items.Parameter name: value  I would like it to accept any value which currently exists in the database. Is this easily achievable? With what you've posted, all I can tell is that you are trying to set the SelectedValue of a ddl to a value that does not exist in the list.  It would be helpful if you can post some code and the expected values of this control.~ Timwww.bucketo...

adding values to the selected value in Dropdown list
 Hi,   I have dropdown box in my page which have some value inherted from the another list box in my page..Now in my second page , i have dropdown box with values and text value and list box... I'll be selecting the one value from the dropdown then i enter the value in text box and click on add button which will add the value in the list box like this i can able to add many value...now if i click on save button for the selected dropdpown item the added values in the listbox should be saved ...like this i add many values for many dropdown item and saved respectivelynow if c...

Updating values of dropdown lists on a page based on a textbox value
Hi Everyone,  I know from the title this seems simple however there is a twist.  I have a page that a user fills out to submit feedback on products.  To keep data clean, I let them select the product, type and size based on dropdown lists, but also want to make it so if they type in the barcode, the values for the Product, Type and Size are looked up and populated on the form for them to see it before submitting the form. The form has several textboxes and dropdown lists that update using SQLDataSource connections.  The problem that I'm running ito is ...

Adding static item to a dynamic dropdown list populated with values from database
How do I populate a dynamic dropdown list with values obtained from the database. The dropdown list should display static text such as "Select a value" when first dispalyed.If this answered your question, be sure to mark it as the answer. DropDownList DDList = new DropDownList();DDList.Text = "Select an Item...";Getting the database data into the combobox depends on what form it's in.  If the data is in a dataset, it's fairly simple to bind to the combobox.If it's more manual, you can always use  DDList.Items.Add();   Hi, Based on my ...

Populate two textboxes based on the values of a Dropdown List Using AJAX
 Hi All,    This is my first AJAX application.I want to Populate two textboxes based on the value of a Dropdown List Using AJAX.Pls guide me on this. RegardsSriRam Hello SriRam, Here are a few resources: http://aspalliance.com/716_Populating_a_DropDownList_using_AJAX_and_ASPNET.4 http://roshanbh.com.np/2008/09/change-textbox-value-dropdown-list-ajax-php.html http://www.w3schools.com/HTMLDOM/prop_option_value.asp This last one here is the code:<html><head><script type="text/javascript">function alertValue()  {  var x=document.g...

Populating dropdown list based on dropdownlist selected value on gridview edititemtemplate
I have 2 dropdown lists in a gridview. While editing the grid I want to populate the EditTask dropdownlist based on the selected item value of the EditProject dropdownlist. I have functions to populate both dropdown lists in the code behind.I have created an event DropDown_SelectedIndexChanged which will fire on changing the project dropdownlist but can't find a way to populate the tasks based on the selected project.   Can anyone help please?    <asp:TemplateField HeaderText="Project" ItemStyle-VerticalAlign="Top&q...

How to use values from two dropdown lists to get the value for a third dropdown?
I have three dropdown lists.  One for Office, one for Department, and a list of employees.   There is no relationship in the database between office and department.  The relationships are to the employees.  What I need to do is take the selected values from Office and Department, and run a query to get the list of employees who match both parameters (Office & Department).  Here's my code for the three dropdown lists.  How do I "connect" Office & Department to populate employees?  code from my vb.net page    for the ...

2nd Data Grid Control
Hi, i have a DataGrid control on page that has a hyperlinked field.  When you click on the hyperlink the page opens, and returns the selected information from the database as it is supposed to.  However, I wanted to put another dataGrid on the hyperlinked page that pulls up more information about the hyperlinked item.  I tried this SQL statement but it returns all the rows of the database, when in actuality all i want it the second dataGrid to show certain columns from a different DB table.   SELECT     tbllog.IttNumber, tbllog.IttLog, tbllog.Lo...

Stuck trying to automatically populate three text fields based on value selected in gridview dropdown list
Hello, When I click on the gridview edit button and select a value from the ComponentID DropDown list I would like fields, tbxFunctions, tbxFuncFail, and tbxFailMode to be updated with the information that matched the ComponentID from tblFailures: Question 1) do I need to create an object data source or sql data source to get functions, funcFail, and failMode by ComponentID Question 2) Not Sure how to set the text property to for tbxFunctions, tbxFuncFail, and tbxFailMode.  Do I add a Select Parameter statement below?  <SelectParameters> <as...

Control.Value and Control.SelectedItem.Value
Can someone explain to me the difference between say, Dropdownlist.SelectedItem.Value and Dropdownlist.SelectedValue?? Just curious, Thanks!Tim These are going to return the same thing. dropdownlist.selectedvalue is a shortcut to get the currently selected value in the dropdown. If that is all you want then you can just use that. If you want to access the currently selected item you can use dropdownlist.selecteditem and that return the item and you can then access any of the item's properties, including in this case the value property. If this post answered your question please r...

Populating a Dropdown after a postback based on another Dropdown's value
In my application, when the user clicks 'Add Row', a row of controls that are created in the code behind. When I click on the dropdownlist for Offices, the page postback and retrieves the value of the Office that was selected. I then want to use this value to populate another dropdownlist with the correct floors for that office. I can get the value of the Office, but I'm having trouble using it. Here is what I have:  public partial class EmployeeOfficeAddress : System.Web.UI.Page { int rows = 0; Label vldOffice = new Label(); Label vldFloor =...

adding values to dropdown list
hello i currently have a code that works by adding values to a drop down list populating it and it works fine but the second i place the drop down list into a edit state under template view in a details view it won't populate the dropdown list current i ust to use DropDownList1.Items.Add(new ListItem(fi.Name, fi.FullName)); // add listitem on give value  and i have tried a number of differtent ways to do it but none of them work my DetailsView is called DetailsView1 anyone got any idea where im going wrong please :) Thanks Andy, Take look to following linkhttp://msdn2.microso...

Web resources about - populating the dropdown list with the values from the data base, Failing near adding the values todropdown - asp.net.presentation-controls

Koalas over-populating Great Ocean Road 'fell out of trees due to starvation'
A koala expert says the culling of more than 700 koalas was necessary because they were "falling out of the trees due to starvation".

Apple begins populating international iBookstores - iLounge News
According to a report from Italian language iPadevice (Translated Link), Apple has begun populating the iBookstores of Australia, Canada, France, ...

Disney is populating their theme parks with robots that can THROW THINGS AT YOU
Disney is hard at work bringing about the Robopocalypse. Behold the throwing bots, the brand-new batch of robots Disney can't wait to unleash ...

Cavuto on Bartiromo at FBN: ‘We’re Populating it with Italians’
Neil Cavuto went on Brian Kilmeade ‘s Fox News Radio show today to talk about the addition of Maria Bartiromo to the FBN line-up. “We’re populating ...

Starbucks Plans to Begin Populating India at Last
Starbucks, the popular American coffee retailer, plans to open its first store in India in September through a joint venture with Tata Global ...

American cougars are re-populating their historical range
American mountain lions, or cougars, are re-emerging in areas of the United States, reversing 100 years of decline. The evidence, [...

Cougars are re-populating their historical range, new study confirms
American mountain lions, or cougars, are re-emerging in areas of the United States, reversing 100 years of decline. The evidence raises new conservation ...

Populating DeLong: Long Form
I have now populated [DeLong: Long Form](http://delong.typepad.com/delong_long_form/) from the present back through the start of 2012for those ...

Cougars are re-populating their historical range, new study confirms
American mountain lions, or cougars, are re-emerging in areas of the United States, reversing 100 years of decline. The evidence, published in ...

Seattle’s unlikely hero? How RealNetworks sparked the region’s startup community
... such as Amazon.com and Microsoft. But the DNA of another company has had a surprising impact on the Seattle startup ecosystem, populating dozens ...

Resources last updated: 1/5/2016 9:30:29 PM