.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Post New Web Links

Trying to use dropdownlist to update db - Not Updating?

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :ASP.Net
I just can't figure out the problem here. I'm trying to first load the two drop down lists with the existing value from the database, then update them if a different value is selected before the Insert button is pressed.  But it's not updating the db when I select a different value. ASPX CODE<asp:SqlDataSource ID="SqlDataSource1" runat="server"         ConnectionString="<%$ ConnectionStrings:HOAConnectionString %>"         DeleteCommand="DELETE FROM [Homes] WHERE [HomeID] = @HomeID"         SelectCommand="SELECT [HomeID], [Subdivision], [Approved] FROM [Homes] WHERE ([HomeID] = @HomeID)"         UpdateCommand="UPDATE [Homes] SET [Subdivision] = @Subdivision, [Approved] = @Approved WHERE [HomeID] = @HomeID">        <SelectParameters>            <asp:QueryStringParameter DefaultValue="1" Name="HomeID" QueryStringField="ID"                 Type="Int32" />        </SelectParameters>   

View Complete Post

More Related Resource Links

Gridview's in Update Panel not updating

I have 2 gridviews in an update panel that for some reason will not update.  There is no data entry, paging, sorting going on, the data is just there to be displayed.  I'm using a timer that initiates every 5 minutes to trigger the updatepanel.  I also have an updatepanel on an additional page where I am also using a trigger to fire the updatepanel with 2 charts and 1 oneline/column gridview.  The 2 charts update just like they are supposed to however the gridview does not. Here is the code for the 2 Gridview aspx page:</head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Timer ID="Timer1" runat="server" Interval="300000" Enabled="True"> </asp:Timer> <br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> <ContentTemplate> <table class="style1"> <tr>

Update statement not updating records and returns no errors

I am running an Update statement against an SQL database on server 2008. The update runs but does not update the record, but returns no errors. The database is part of a commercial help desk package called TrackIt 8.5 which was just a fresh install on a new web server and a new sql server. The update is running from a web form we use to automatically create active directory accounts. After the account is created the web form closes out the work order in the Trackit db. This was working fine when the system was running on Server 2003 and SQL server 2005. Running Trackit version 7.02. The login use to access the database has full permissions to read and write to the database, just as it did on the old server which never had an issue updating. Odd thing is, if I log onto the SQL server and make a change to any single field in that record. I can then run the web form and it updates the record normally. All other update statements that are running on other databases are running fine. Anyone have any suggestions on what to check that may be causing this issue?

update SharePoint calendar while updating Outlook Calendar


Is it possible to synchronize calendars between Outlook and SharePoint such that a user in Outlook can elect, on any given calendar entry, to have that entry post to a SharePoint calendar AT THE SAME TIME?  Our division has a presence on our SharePoint intranet site.  On the site is a calendar that shows vacation time of all division employees.  What we hope to be able to do is that when an employee enters there vacation on their own Outlook calendar, that it updates the Employee Vacation Calendar on the SharePoint site too. 

I am aware of the ability to synchronize calendars, and have the SP calendar show up in Other Calendars in Outlook, and then drag a copy from the Outlook calendar to the SharePoint calender as shown here: http://sharepoint.microsoft.com/Blogs/GetThePoint/Lists/Posts/Post.aspx?List=8d9e2a99-f288-47c2-916b-2f32864f7b82&ID=73&Web=5e4647a0-e7d0-4626-b71c-b1ff06402465, but we are hoping to even eliminate that copying step.

Database update, treeview is not updating


I have a treeview that i fill from a database, when i add a new row to a database, the treeview is not updating.
Even the reload of an internet explorer doesn't help, It does updates only after i press stop debugging button and turn it on again.
Here is the code:

    private void MenusBuilder()
        //Parent menu extraction
        DataSet1.TreeItemRow[] cr = GetTreeItemRows();

        StringBuilder sb = new StringBuilder();
        sb.AppendLine(@"<?xml version=""1.0"" encoding=""utf-8"" ?>");
        sb.AppendLine(@"<div id=""menu"">");

        string XmlSiteCreator = CreateXmlDataSource(cr, sb);

        XmlDataSource1.Data = XmlSiteCreator; //Tree Menu
        TreeView1.DataSourceID = XmlDataSource1.ID;

    public static DataSet1.TreeItemRow[] GetTreeItemRows()
        using (DataSet1TableAdapters.TreeItemTableAdapter tita = new DataSet1TableAdapters.TreeItemTableAdapter())
            DataSet1.TreeItemDataTable tidt = tita.GetData();
            DataSet1.TreeItemRow[] pmr = (from f in tidt select f).ToArray();
            return pmr;

(XmlSiteCreator returns the right xml f

Nested updatepanel updating all the update panel



I have one update panel which is having tPlaceholder which is loading dynalically.

<asp:UpdatePanel ID="UpdatePanel_ForumContent" runat="server" UpdateMode="Conditional">
            <asp:PlaceHolder ID="ForumTopicPlaceHolder" runat="server" Visible="true"></asp:PlaceHolder>

in the CS file on page load, adding Placeholder dynalically

 Control ForumTopicTabControl = LoadControl("Topic.ascx");
                Assembly objAssembly = BuildManager.GetCompiledAssembly("~/Topic.ascx");
                Type objType = objAssembly.GetType("Blogs_ForumTopic");
                PropertyInfo objProperty = objType.GetProperty("TableName");
                objProperty.SetValue(ForumTopicTabControl, dr["TopicTableName"].ToString(), null);
                objProperty = objType.GetProperty("HeaderName");
                objProperty.SetValue(ForumTopicTabControl, dr["Name"].ToString(), null);
                objProperty = objType.GetProperty("HeaderDesc");
                objProperty.SetValue(ForumTopicTabControl, dr["Description

Div tag not updating in update panel




I need to update the div tag based on the selection made in the dropdownlist. I'm not able to update my div tag. Could you please trace out where I'm going wrong ?


My code goes like this:


<asp:UpdatePanel runat="server" ID="updatePortRegion" UpdateMode="Conditional">

<asp:DropDownList ID="ddlPortRegion"  OnSelectedIndexChanged="ddlPortRegion_SelectedIndexChanged" AutoPostBack="true" CausesValidation="false" runat="server" Width="150px">
<asp:ListItem Text="Select a Port Region:"></asp:ListItem>


        <asp:HiddenField ID="hidPortId" runat="server" />
        StringBuilder localFieldNames = new StringBuilder();
        ArrayList localFields = helper.buildLocalFieldHTML(offeringOID,regionid);
            if (localFields.Count > 0)

                    divSpecData.InnerText =(String)field["code"];

                divSpecData.InnerHtml = "<font class='smalltext'>No specifi

Dropdownlist is not updating the table

I am wondering what I need to correct , Detailsview is in ReadOnly mode. 
  <asp:BoundField DataField="ShipTo" HeaderText="ShipTo" SortExpression="ShipTo" />
                <asp:TemplateField HeaderText="PaymentMethod" SortExpression="PaymentMethod">
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("PaymentMethod") %>'></asp:TextBox>
                        <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="AccessDatasource1"
                            DataTextField="PaymentType" DataValueField="id">
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("PaymentMethod") %>'></asp:TextBox>
                        <asp:Label ID="Label1" runat="

Update through Dropdownlist and button in GridView


Hello guys, I am a newbie in Asp.net, I can't update my database by using dropdownlist and click Update Button in the GridView,

This is the picture of my GridView:

Here is my codes:

<asp:TemplateField HeaderText="Status">
                    <asp:SqlDataSource ID="SqlDropdownStatus" runat="server"
                        ConnectionString="<%$ ConnectionStrings:fypnewDBConnectionString %>"
                        SelectCommand="SELECT DISTINCT [status] FROM [title]"></asp:SqlDataSource>

Update databse with DropDownList in GridView, SelectedIndexChanged


I am new to asp.net (I may use some incorrect termology while I explain my issue...) and need some help with DropDownList in Gridview.  Currently I have a GridView set up with three Columns bound to a database: Column1 - some kinda of index, Column2 - string, Column3 - DropDownList(called Active).  So far when I build the page, all the columns show up and the DropDownList appears and the values are bound correctly.  I want to change a value in the DropDownList and automatically update that value in my database. 

I have set AutoPostBack = true and I made a DataObject (called UpdateActive) to update the database (it takes 2 inputs, the Column1 index and Column3 DropDownList value).  However, I don't know how to find the row that I am changing, is there a way to figure out what row it is (like finding the Column 1 index?).  Also, I don't want to have to click a button to update the data.

                        <asp:GridView ID="gvWorkflowStepOrder" runat="server" AllowPaging="True" AllowSorting="true"
AutoGenerateColumns="False" DataKeyNames="WorkflowStepOrderID" PageSize="50"

ADO RecordSet Update Fails (Insufficient key column information for updating...)


Hi, I'd like to update one field in a recordset but I'm getting this error:

*** insufficient key column information for updating or refreshing" ***

My program consists in a .VBS file (VbScript), and the code goes as follows:

connectionString = "Provider=SQLNCLI; DataSource=dbABC;Initial Catalog=whateverCat;Integrated Security=SSPI"

set objConn = CreateObject( "ADODB.Connection" )
set objRs = CreateObject( "ADODB.RecordSet" ) objConn.ConnectionTimeout = 0
objRS.CommandTimeout = 0
objRS.CursorLocation = 3 ' adUseClient
objRs.LockType = 3 ' adLockOptimistic
objRs.CursorType = 2 'adOpenDynamic
objConn.Open ConnectionString
objRs.Open "Select ComputerID, ComputerName From ComputerTable", objConn
do until objRs.eof
objRs( "ComputerName" ).Value = "NewComputerName"
objRs.Update ' ****Fails here

I don't need that the changes made in the RecordSet to be propagated into the DB table, so perhaps here is my problem: I do only have read access to the tables. Could this be the problem? Thanks.

ASP.Net Gridview Edit Update Cancel Commands

In ASP.Net 2.0, GridView Control also provides the functionality to edit and update the data retrieved from the database using CommandField template. You can cancel the action using Cancel Command of the CommandField. GridView consists of events that can be used to perform the actions like edit, update and cancel upon the Data items displayed in the ASP.Net GridView Data Control.

jQuery: Styling DropDownList Alternating Items (Rows)

In the following example, I will show how you can style any asp:dropdownlist very easily.

The example demonstrates how you can change alternating row items background color, using the fadeTo() to add a nice touch in the dropdownlist. You can change alt rows with a couple lines.

How to format and update GridView and DataGrid rows using JQuery

The behavior described in this question is as expected. When you set text of a cell in grid, it directly affects HTML that is going to be rendered. When you set text value of a cell, it means that you are setting innerText of the cell. The column that GridView creates for command fields (Edit, Delete and Select) are a (anchor) or button elements. So you can see what will happen if you set text value in that cell. It will wipe out those link or button controls and replace them with simple text string.

Working with DropDownList and ListBox Controls in ASP.NET

"In my application i am using dropdownlist to display all categories from a table. When the user clicks this control I display all records in that category. Category table also contains column called color.

I wanted display some categories in dropdown list different color and others in different color using ASP.NET."-Anonymous

ASP.NET DropDownList Web Control, Part 1

Anybody with much experience in ASP has written an include file function for populating the contents of a SELECT dropdown list with entries from a database. Some of the more advanced users have even gone so far as to add caching to their function to reduce database hits for these rarely changing menu options. Naturally, these same techniques are going to be used with ASP.NET, but with a new programming object model. ASP.NET provides a web control, the DropDownList, which can be used for the same purposes as our custom built SELECT tag from Classic ASP.

Declaring a DropDownList in ASP .Net

A DropDownList is also commonly known as combo box. It can contain multiple data members, but unlike a normal list box the users can choose only one value from this control. Though the functionality of this DropDownList is much like a Single Row Select List Box, a DropDownList can save a lot of GUI space as it is rendered on a Single line and is expanded only when the user clicks on the Control

Multiple Column Dropdownlist for the ASP.NET DataGrid

Based on my previous control "Multiple Column DropDownList for ASP.NET", I received many emails asking for the same control to be used in the DataGrid for web applications. Here we go.. This control can be used as the regular MS DropDownList in the DataGrid and also as a regular dropdownlist. It has all the properties, like DataTextField, DataValueField, DataSource, SelectedIndex etc. The download file contains the samples both in VB.NET and C#. In this sample, I have used the Northwind database of SQL Server.
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