.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

Problem binding data to DropDownList in DetailsView

Posted By:      Posted Date: September 15, 2010    Points: 0   Category :ASP.Net
Hi guys. I have a slight issue I awas trying to fix for 2-3 days, but nothing I try works. The scenario: DetailsView control in edit mode, I pass parameters to the SqlDataSourceProducts (edit.aspx?id=2) and the data source selects the appropriate data and fills in the DetailsView form. Except two drop down lists. These two DDLs (DDL2 and DDL3) are dependent on the previous DDL (DDL1) in the DetailsView. Thanks to PeteNet, when the selected value of the DDL1 changes, DDL2 and 3 change their lists and get bound to the database. The problem is: when I edit something from the database, DDL2 and 3 appear empty and when I update any other field and leave these, they get blanked in the database.  My goal is to set the selected value of DDL2 and 3 to the values in the database WHERE ID = QueryStringField="id". I can go for not binding the data unless the field is changed, but does not sound professional and user friendly. code: The SqlDataSource used to select the parameters from the table and populate the DetailsView <asp:SqlDataSource ID="SqlDataSourceProduct" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT ID, wm_number, upc, check_digit, unit, price_unit, brand, category, shelves, type, cooking, storage, packaging, origin, nutriti

View Complete Post

More Related Resource Links

Data Binding to Dropdownlist


   private void AddDBDataToControl(DataSet app_Support,int count)
        int i = 0;
        while (count != 0)

            DateTime dt = Convert.ToDateTime(app_Support.Tables[0].Rows[i]["FromDate"].ToString());

//dt=23/08/2010 10:04:00 AM

            DropDownList h1 = (DropDownList)GVDate.Rows[i].Cells[1].FindControl("txthour");
            h1.SelectedValue = dt.Hour.ToString();
            DropDownList m1 = (DropDownList)GVDate.Rows[i].Cells[2].FindControl("txtmin");
            m1.SelectedValue = dt.Minute.ToString();

            DropDownList h2 = (DropDownList)GVDate.Rows[i].Cells[5].FindControl("txthourto");
            DateTime dt2 = Convert.ToDateTime(app_Support.Tables[0].Rows[i]["To

Weird problem in Detailsview - Dropdownlist in



I'm new in this forum and I really hope you'll be able to help me.

I converted a field in the detailsview into a template field and put a dropdownlist in the <InsertItemTemplate> and it worked great. This is the code I put:

<InsertItemTemplate><asp:DropDownList runat="server" DataSourceID="sdsGenresPossible" DataTextField="Genre"  DataValueField="Index" SelectedValue='<%# Bind("Genre") %>' ></asp:DropDownList></InsertItemTemplate>

Now, I tried to do the same thing for the <EditItemTemplate> . This is the code I put there:

<EditItemTemplate><asp:DropDownList runat="server" DataSourceID="sdsGenresPossible" DataTextField="Genre" DataValueField="Index" SelectedValue='<%# Bind("Genre") %>' ></asp:DropDownList></EditItemTemplate>  

When I change the DV properties I do see that a dropdownlist was  added but when I run the program and click on "Edit" in the DV nothing happens (however when I click on "Insert" it works fine).

This is the Select command for the data source I used:

<asp:SqlDataSource runat="server"

wpf charting column series data binding problem

I'm trying to build a chart using the columnSeries from the wpf toolkit and I appear to be having trouble with the data binding. Here is the xaml: <Grid>    <chartingToolkit:ColumnSeries Height="18" HorizontalAlignment="Left" Margin="188,169,0,0" Name="columnSeries1" VerticalAlignment="Top" Width="18" IndependentValueBinding="{Binding Path=Date}" DependentValueBinding="{Binding Path=Value}" /></Grid> In the code behind, I'm calling a stored procedure and putting the result in a datatable like this: string connString = ConfigurationManager.ConnectionStrings["string"].ConnectionString;            using (SqlConnection cn = new SqlConnection(connString))            {                DataTable dt = new DataTable("T1");                cn.Open();                SqlCommand cmd = new SqlCommand("T1_sp", cn);                cmd.CommandType = CommandType.StoredProcedure;                  SqlDataAdapter da = new SqlDataAdapter(cmd);                da.Fill(dt);                columnSeries1.ItemsSource = dt.DefaultView;                cn.Close();            } No error is being generated but I'm not getting a column chart either. If I take the same command and put it into a datagrid, it works fine. What do I need to do to get this into my column chart? If it helps,

ajax combobox having problem in binding data

Hi i am using ajaxtoolkit:combobox and i tried to bind data to this control in code behind file. but it is taking 3 to 4 mints to bind data and display the page. what is the problem? I am providing my aspx code and code behind code here<%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="TestPage.aspx.cs" Inherits="Dashboards_TestPage" Title="Untitled Page" %> <asp:Content ID="Content1" ContentPlaceHolderID="cphMain" Runat="Server"> <asp:ScriptManager runat="server" ID="scriptMgr"> </asp:ScriptManager> <table border="1"> <tr> <td> <ajaxToolkit:ComboBox ID="ddlProgram" runat="server" DropDownStyle="DropDownList" AutoCompleteMode="SuggestAppend" CaseSensitive="False" MaxLength="10"> </ajaxToolkit:ComboBox> </td> </tr> </table> </asp:Content>  Code behind code:public partial class Programs_TestPage : System.Web.UI.Page { ProgramData programData = new ProgramData(); protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack)

Problem Binding DropdownList in a gridView to a datasource

I have a Dropdownlist in an itemTemplate in a gridview. My gridView binds to dataTable1 (from which the selected value for dropdown comes from) and dropDown binds to dataTable2 (i need to get DataValueField and DataTextField from here).<asp:TemplateField HeaderText="Category"> <ItemTemplate> <asp:DropDownList ID="Cat" runat="server" SelectedValue='<%#Bind("CATEGORY") %>' > </asp:DropDownList> </ItemTemplate> <FooterStyle BorderStyle="None" /> <HeaderStyle BorderStyle="None" /> <ItemStyle BorderStyle="None" /> </asp:TemplateField>How do I do that? thanks in advance!

FormView custom data binding problem

Hi there,   I'm using VWD 2010 ASP.NET 4.0 and SQL Server 2008 Also I have login page with the ASP.NET configuration   one of my page has FormView with Update feature   Evryting works fine user login go to my FormView page and update the record.   Now I created a simple function   Protected Function GetUserName() As String        Return User.Identity.Name    End Function   and one of my coloumn call EditedBy   I replaced the Bind("EditedBy") field binding with   Custom binding GetUserName()   When user update it show the current user login name on the screen But it won't show in the table itself (it show null value when i do select statement)   I used to do this with ASP.NET 2.0 with no problem?   How do I fix that?   Thanks, Oded Dror  

GridView column/row data binding problem

Hi All, I have a table with the following structure: Attribute------------- AttributeIdWeekNoDayNoAttribute1Attribute2Attribute3Attribute4Attribute5 ........ likewise. I want to display these data in a gridview in the following manner                                  Sunday    Monday Tuesday ............ (till Saturday) - should be gridview columns, I can retrieve this using dayno Attribute 1 Attribute 2 Attribute 3 Attribute 4 .......... like wise attributes should be taken in to rows.Is this possible in a gridview, if so how can I do that?

Binding data to chart problem


Hi all

I'm trying to build a chart in my application which will act as a client for an ASP.NET 3.5 web service that I created. The error I get is as follows:

Series data points do not support values of type System.Data.DataViewManagerListItemTypeDescriptor only values of these types can be used: Double, Decimal, Single, int, long, uint, ulong, String, DateTime, short, ushort.

I've tried various ways to resolve this but can't. This error points at the chtStats.DataBind() line in the code below:

    Private Sub frmStatsReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'create a new instance of the service
        Dim serv As New BhpService.ServiceSoapClient
        'get a dataset with the response from the service
        Dim ds As DataSet = New DataSet()
        ds = serv.ViewSalesStats()
        'create a DataTable with the values of the Bookings table from the dataset
        Dim dt As DataTable = ds.Tables("Bookings")
        'create the x axis values which is the Event name
        'and therefore column 1 in the datatable
        'this represents to t

Data Binding & Autoincrement primary Key Problem


I'm developing a small database using <acronym style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 1px; border-left-width: 0px; border-style: initial; border-color: initial; font-variant: normal; border-bottom-style: dotted; border-bottom-color: #000000; cursor: help;" title="Visual Basic">vb</acronym>.net and MS SQL Server in MS Visual Studio. I developed a data source from the database and dragged a table onto a form in the project using the Data Binding Technique (so all code was automatically generated).
My problem is that I'm unable to auto-increment my primary key on my form. 
When I click 'add new' on the navigator toolbar on the top, the ID textbox (which holds the primary key), stays empty, as no number enters the textbox, not even -1 as I have seen on other example databases. Therefore I'm not able to save information.
When I add data manually to the database, it increments fine as I have set these properties in the database:
  • Identity Spec = yes
  • Is Identity = yes
  • Identity Increment = 1
  • identity seed = 1
Am I leaving something out? Any help would be appreciated.
Thanks i

Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

Binding WPF Controls to an Entity Data Model

In this interview, programming writer, McLean Schofield, demonstrates how to bind WPF controls to an entity data model, using Visual Studio 2010 Beta 1. You can also learn more in the topic: Walkthrough: Binding WPF Controls to an Entity Data Model.

styling dropdownlist problem


Dear All,

im facing a problem while styling my ddl, what i did is:

<div><asp ropDownList ID="DropDownList1" runat="server" style="background-color:Transparent;" Width="100%">
    </asp: dropDownList></div>

<div class="stlGradient">
<asp ropDownList ID="DropDownList1" runat="server" style="background-color:Transparent;border:none;" Width="100%"></asp: dropDownList>

the DIV style is having a bg image repeated X.

now this worked on Firefox
on google Chrome: the border gone but the background still white
on IE 7: nothing happend

thanks for helping.

MySql.Data assembly problem



I added refernece MySql.Data to my project. My web.config looks like that:

<?xml version="1.0"?>
                <add assembly="MySql.Data, Version=, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>

But when in ServerExplorer I try "Add Connection..." I can't find "MySql Database" in the "Choose Data Source" dialog box?

What the problem can be?

Cutting Edge: Live Data Binding in ASP.NET AJAX 4.0


Dino Esposito discusses various forms of client-side data binding as they are coming out in ASP.NET AJAX 4.0, focusing on some advanced features of data binding and observable objects.

Dino Esposito

MSDN Magazine December 2009

Cutting Edge: Data Binding in ASP.NET AJAX 4.0


In this article, Dino reviews the pillars of real-world AJAX development as supported in ASP.NET AJAX 4.0. In doing so, he mostly focuses on client-side templates and data-binding but doesn't ignore other goodies, such as ADO.NET Data Services proxy classes and programming facilities.

Dino Esposito

MSDN Magazine October 2009

Dynamic WPF: Create Flexible UIs With Flow Documents And Data Binding


Flow documents offer enormous flexibility in arranging text layout and pagination, but they don't support data binding, so you can't dynamically change content. Here we build a component to solve that problem.

Vincent Van Den Berghe

MSDN Magazine April 2009

Data and WPF: Customize Data Display with Data Binding and WPF


Here we present techniques for programmatic and declarative data binding and display with Windows Presentation Foundation.

Josh Smith

MSDN Magazine July 2008

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