.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

Update through Dropdownlist and button in GridView

Posted By:      Posted Date: October 26, 2010    Points: 0   Category :ASP.Net

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>

View Complete Post

More Related Resource Links

Update a field in a gridview to False on a Button Click

 Hi, Ive got a list of records in a gridview (from an SQLDataSource) where a field value is set to True.  I've also added a "reset" button in a template field at the start of the row in the Gridview. What I would like to do is allow the user to click the reset button on a particular row and 'reset' the true value to 'false' (updating the source data). Are there any idiot proof tutorials to do this??? Many thanks for your help! Fiorano

Add Dynamically TextBox And DropDownList In Gridview on Button Click Wich is placed outside of Gridv


Hi All,

   I have Gridview and Button Control on Form.i want to Add Dynamically TextBox And DropDownList In Gridview on Button Click Wich is placed outside of Gridview.

When i click on Button -> One TextBox and One Dropdownlist which contains values bydefault 1,2,3 should bind to gridview.    Button is placed outside Gridview.

Thanks in advance.

Update a field that isn't in the row using a button in gridview


I have a gridview which shows a list of data... at the end of each item I have added a button which is linked to the onclick event... when a button is clicked I want a value to update on that specific row... but I can't get it to work :( my code is below...

SqlDataSource 1 code...

UpdateCommand="UPDATE [PurchaseProduct] SET [BDConfirmSent] = 'Yes' Where [Id] = @Id">

            <asp:Parameter Name="Id" />
            <asp:Parameter Name="BDConfirmSent" />

Code Behind...

Protected Sub SqlDataSource1_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Updating

        e.Command.Parameters("@BDConfirmSent").Value = "Yes"

End Sub

Protected Sub Button1_Click()


End Sub

When I click the button it just postsback the page but then the [BDConfirmSent] field is still empty instead of being "Yes"

Add a button to update in 1 click to a gridview control


Hi all, I know that from the title probably everyone is going to think, "why add an update if is already there!"  the reason is because I want to update/delete/add with one click, instead of click the edit button, modify the data and then click the update button.

This is my scenario, I have a gridview with information of tools(screw driver, hammer, etc) one of the columns is the status, so what I want is to add a button that the user can click and chance the status from "Assigned" to "Active" this is what I have so far:

<asp:GridView ID="GV1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                        DataKeyNames="IdTool" DataSourceID="Tool" ForeColor="#333333" SelectedRowStyle-BackColor="AliceBlue"
                        SelectedRowStyle-Font-Bold="true" Width="605px">
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                            <asp:TemplateField ShowHeader="False">

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"

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.

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.

Problem to group radio button across gridview rows

In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:

Maintain HTML Radio Button Selection Inside GridView After Postback

Long time ago I wrote an article about getting the value of the selected RadioButtons inside the GridView control. The code did not addresssed the postback issue which means that the selected radio button was cleared after the postback occurs.

A Simple and Extensible Radio Button Style GridView

The GridView is one of the significant controls in ASP.NET 2.0 and later versions. No doubt it reduces a lot of work time. However, customizing the GridView control is not an easy task. For example, it's hard to add a radio button column to the GridView. This article demonstrates the reason why a radio button column cannot act as normal and how to create a simple and extensible radio button GridView.

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

How to bind GridView and DropDownList controls using DataTable object

In .net framework 2.0, you can load a DataTable in memory by consuming a data source using a DataReader. In this version you will find the flexibility in accessing the DataReader means write access code once and use again and again using DataReader. To see the functionality of DataTable consider an example that is created using VS2005.

Add, Edit, update, Delete gridview

The article Add, Edit, update, Delete gridview was added by anjankant on Friday, July 09, 2010.

Thousandas operation we can do on Gridview control. Here I as explaining how we can add new recored and edit of existing record and delete a record in Gridview. Step1 : You can add this gridview in your aspx form. Here some events of Gridview are fired

Gridview with Image Button


i have a gridview and i want to perform edit and delete with an image button

but unable to figure out the events and how i m gonna make my grid into edit mode ??

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                <asp:TemplateField HeaderText="S.No">
                        <asp:Label ID="Label1" runat="server" Text='<%# Container.DataItemIndex+1 %>'></asp:Label>
                <asp:TemplateField HeaderText="Edit">
                        <asp:ImageButton ID="ImageButton1" runat="server" ImageAlign="Middle" 
                            ImageUrl="~/image/ico_edit.gif" CommandName="Edit" 
                            onclick="ImageButton1_Click" />
                <asp:TemplateField HeaderText="Delete">

update parentpage gridview with the values from child page?


hi   i am having a gridview on each row i am having a update and add button.

on click of either of the button i am opening a popup where the end user will enter data and on clck of ok button in the child page

based on the click ie

if i clicked update i need to update that particular row with the values from child page.

if i clicked on add i need to add a row below the row where i clicked add button .

can anyone help me with this?

Multiple update statements per row in Gridview Edit


I want to set up a gridview that will display data like this

WeekEndingDate Project Category Sun Mon Tues Wed Thu Fri Sat
8/14/2010      proj1   test     2   1   2    3   2   1   0
8/21/2010      proj1   test     0   2   2    2   2   1   0
8/28/2010      proj1   test     0   1  

Gridview Update outside of SqlDatasource


Is it possible to use a SQLDataSource to populate a gridview but not use the SQLDataSource for Updating?

I wanted to add the update code in the Gridview_RowUpdating event since it is a complex update I need to do.

I get this message when i click the update button

Updating is not supported by data source 'SqlDataSource1' unless UpdateCommand is specified.

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