.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 a field in a gridview to False on a Button Click

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
 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

View Complete Post

More Related Resource Links

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">

Gridview and delete option - Button click displays message

Hi, I have a gridview connected to a sql database that allows the user to delete the record. I used the ASP.net automatic "options" for this. However, I would like when the user deletes a record, a message (textbox) appears in the form to say the record has been deleted. Please can anyone provide some sample codes?   Thanks in advance. Nijojo.

Build xml file from gridview values on button click

We are looking to add GoogleMaps to our application. With that said we are going to be using the geocoding api to pass in the lat and long values to pin point locations on the the map. Reading thru the documentation we can pass in the values via XML, so we would like to see how we can take the lat and long values from our gridview and pass that to the API if and when somone clicks on the button to show the map.. The process will work like so, you arrive at the search page, you complete a search, in most if not all cases, you will always get multiple results presented in a gridview. If you should to view them all on the map, you click button and it needs to map out each location on the map. So is there anyway to pull from the gridview the lat, long and description to pass into the API?   Any links to sites that i can review would be great. thanks. 

SQL Update command on button click

Hello!I don't know what is the problem with my code. SQL statement is good (I checked it outside of the application) but for some reason it doesn't update the data.Let me explain a bit better. I have a web form which is supposed to be used for editing data in textboxes and on button click the data should be updated via SQL query.public partial class Administracija_Clanak : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string ClanakID = Page.Request.QueryString["idClanak"]; String connString = WebConfigurationManager.ConnectionStrings["CMS"].ToString(); SqlConnection conn = new SqlConnection(connString); conn.Open(); using (SqlCommand command = new SqlCommand("SELECT Clanak.* , Kategorije.naziv FROM Clanak Clanak INNER JOIN Kategorije ON Clanak.idKategorije = Kategorije.idKategorija WHERE Clanak.idClanak='" + ClanakID + "'", conn)) { SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { txtIDClanak.Text = reader.GetInt32(0).ToString(); ddlKategorija.Text = reader.GetInt32(1).ToString(); txtNaslov.Text = reader.GetString(2).ToString(); txtAutor.Text = reader.GetString(4).ToString(); txtSadrzaj.Content = re

Chrome update.. Ajaxtoolkit TabContainer disappears on button click.

Hello,Yesterday (Thursday Sep 10th 2010) I was happy to have a TabContainer working fine on a simple page as im learning to use it.On the page was:1) Ajax Script manger.2) 1 command button (it would make label1.text = "hello world"3) A Ajax TabContainer with 2 tabs... 4) Label1 That was it and it was working fine in Chrom and IE Woohoo.. I go home...This morning I load it up to keep working way and doing more with it.... Chrome is my default browser, it loads and I click tab2 then tab 1 all is well.... I click Butto1 and the hole TabContainer disapears..After much dinging I find it still works in IE but that my Chrome has updated (on its own): (I notice only one ICON in Chrome in the uper right corner by the addres bar... Only the Wrench ICON, No more Page ICON.. So I check and sure enough Chrome did a push to V 6.0.472.55.. thanks for asking me Google...) Anyhow thats the difference and now TabContainer goes poof/disappears when clicking a button that refeshes the page.Any thoughts?Others having this problem?ThanksShane 

how to update multiple row in one update button click

hi all,   im having a gridview in which im displaying records and status.....this gridview shows employee applied leave waiting for approvals.. so in gridview i have chabged the status button as radio button list and giving two choices as approve/reject ....so HOD seect relevant button and update the grid... how to do this? 1) do i need to place a button on footer and do some write code behind? 2) or any other easier way?

Insert/Update data to multiple tables on a single button click


Hi experts,

I need to insert/update data to 3 or more tables on a single button click.What is best method for achieving this?I am using mysql as my DB.

Thanks for your valuable reply in advance.

Gridview Link Button control click event


Respected Reader,

I have  Web page that uses LinkButton control inside Template Fields of Gridview.

I am trying to work on LinkButton Click event and trying to preserve the Value of LinkButton that user click, and based on that value, i want to refresh tha page data.

I used CommandName and CommandArgument property of Linkbutton, but i can use that property only in GridView_RowCommand method by checking e.CommandName expression. But the problem with that Gridview_RowCommand event fire after all other page_load activity. So the value never used in the page_load event to refresh the data in all other control.

I also tried to use OnClick Method, Session variable and Hidden variable. but when i run Response.Redirect method from Gridview_RowCommand, it clear all the Session and Hidden variable values. also tried (Response.Redirect(,false)) method but never got success.

Any suggestion will be appricated in advance.

Cannot add new row to gridview on button click



I got a function to load a grid view and works fine. Then, I got a button, when click, I wanted to add a new row into the grid, what I did is I add a new to to the dataset and rebind the dataset to the grid view.

The problem I faced is that is it able to add a new row, but it only shows ONE column only, which is the most left column.

protected void gvDetail_AddNewRow(object sender, System.EventArgs e)
            string strSQL = null;
            DataSet ds = new DataSet();

            lblError.Text = "";

            strSQL = "Select * From tmp_Detail_Data_vaio1045xjh02l55bw4vtrmg_09282010_132652";

            ds = clsDataAccess.clsDataAccess.RetrieveDataSet(clsDataAccess.clsDataAccess.ConnStringDataCollection, strSQL);

            if (ds != null)
                ContentPlaceHolder myContent = (ContentPlaceHolder)Page.Master.FindControl("CPHDetail");
                GridView gvView = (GridView)myContent.FindControl("gvDetail");


                gvView.DataSource = ds;




Any help?

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 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>

Using Button Field in GridView?

In .NET 1.1 to put in a link to download files from my server I used a Button Field in a DataGrid.

In .NET 2.0 I am trying to do the same with a GridView. 
In the Source of my page I put in <asp:ButtonField Text="Download" CommandName="Download"/>.
Then for the code behind I put in
Protected Sub GridView1_Download(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        If e.CommandName = "Download" Then
        End If
    End Sub
Download was a fuction and (e.Item.Cells(4).Text) would be the path to the file.  I noticed in a GridView I can't use
Is there a different way to do this?  Or should I not use a ButtonField and use something else?

How to Resize Button Field in gridview if we use Google chrome browser


Hi Everybody,

  I am using google chorme to test my asp.net application. In that <asp:buttonfield> control with in gridview is not resized. I am able to rotate text using following code.

 -webkit-transform: rotate(90deg);

But I am not able to resize the <asp:buttonField>.Please help me to resolve this.

Thanks in Advance.



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:
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