.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

Gridview's cell have changed

Posted By:      Posted Date: September 23, 2010    Points: 0   Category :ASP.Net


   does anyone know if the gridview can tell you if a cell's contents have changed (during an edit) in order to determine if an update should be made against the database?

View Complete Post

More Related Resource Links

gridview sort on changed cell text


I have a gridview that is being databound by an SQLdatasource and on  RowDataBound i am doing a calculation and then setting


e.Row.cells(17).text = Result


However, when I go to sort it on the website it sorts it based off the previous values.


Cell(17) from the datasource reads in all 1's. The numbers I change it to range from 0 to 15. So when I click sort nothing changes because it sees it as all 1's.

How can i make the gridivew sort off the changed text values?

How can i add a textbox into a GridView Cell dynamically and how can i retrieve entred data

Hey, i think that the the subject can explain what i need, it's about adding a TextBox control with the code behind into a GridView, and also about how can i retrieve entered data after submitting, im using C#,Thanks.

I need to set the value of a gridview cell during update.

Hi,  I've been reading the posts here and I'm not finding, or maybe just not understanding, the answer I need so here's my problem. I have a small gridview and the update works very well. The issue is I need to have one of the fields set to a value from my code either when the record is open for undating or when the update runs.  Here is my gridview and the datasource info:<asp:GridView ID="GridViewItemLog" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" CellPadding="3" DataKeyNames="LogID" DataSourceID="SqlDataSourceItemLogEntries" GridLines="Vertical" onrowdatabound="GridViewItemLog_RowDataBound" onrowupdating="GridViewItemLog_RowUpdating" onrowediting="GridViewItemLog_RowEditing"><AlternatingRowStyle BackColor="Gainsboro" /><Columns><asp:CommandField ButtonType="Image" CancelImageUrl="~/Resources/StopSmall.png" EditImageUrl="~/Resources/EditSmall.png" ShowEditButton="True" UpdateImageUrl="~/Resources/Save.png" /><asp:Boun

Checkbox checked changed event inside gridview

Hi All, In my gridview there are 8 checkboxex in each row : 'Sunday' to 'Saturday' and one for 'All'. If 'All' is checked in a particular row, all other checkboxes in that row should be checked instantly, and viserversa. Can i do this in checkbox checked_changed event, if so how do i access the current row of the gridview in the checked changed event? Thanks in advance

ASP.NET GridView help!! Need to be able to scroll an individual cell up and down.

Hi everyone.  I have an ASP.NET GridView displaying the below grid.  As you can see, the column on the right has a LOT of text and it stretches the column.  I need to be able to set a fixed width for JUST that column (maybe like 200px) and have vertical scroll bars on that cell so the user could scroll down to read the rest of the text, is that possible to do?Here's my markup: <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource2" AutoGenerateColumns="False" AllowPaging="True" AlternatingRowStyle-Wrap="False" CellPadding="4" ForeColor="#333333" GridLines="None"> <RowStyle Height="30px" BackColor="#EFF3FB" /> <Columns> <asp:BoundField DataField="Customer_Name" HeaderText="Customer" SortExpression="Customer" /> <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" /> <asp:BoundField DataField="Module" HeaderText

Gridview attribute changed by javascript is lost on postback

I have a gridview control that extends the default gridview.  I have added an attribute called "hiddenSelectedValues" to to the gridview during the "PreRender" event and I have a private variable that points to the value of that attribute. I have some javascript code that modifies the value of this attribute based on the user checking or unchecking checkboxes in the grid.  I have confirmed that the javascript is indeed modifying the value of the "hiddenSelectedValues" attribute by using Firebug to see the change as it happens. However, once a postback occurs, the grid looses the updated value of this attribute and I am unable to reference get the updated value on the server side. How do I keep the value of an attribute changed by javascript on postback?

Javascript code to copy specific cell of gridview row

Dears, I need a javascript code to copy the text content of a cell of a row in gridview. I have a button in each row that users click it and the text content a cell of that row should be copied in a textbox out of gridview

Gridview Cell Hightlight with toggling

Hi, I have a dynamically generated Gridview wherein every tablecell within the gridview is assigned a particular class(background color) at run time. Each cell has  a linkbutton and I have a onClientClick event where, I would like to highlight the container cell when the user clicks on the linkbutton.If the user clicks it back, I would it to  get back its original class/background color that it was bound with earlier. I am trying to implement this in Javascript by passing the original className but I am unable to toggle the color back to original.Please help. Here is a snippet of code. I could do it in c# but I would like to implement this in Javascript as it won't  cause postback.Thanks so much!//Linkbutton databinding event private void lb_DataBinding(Object sender, EventArgs e)     { private void lb_DataBinding(Object sender, EventArgs e)    { LinkButton l = (LinkButton)sender; l.OnClientClick = String.Format("doClick({0},{1},'{2}','{3}','{4}','{5}','{6}'); return false;", x, y, className, tbPercentSoldUpfrontSelected.ClientID, tbPercentChangeDemandSelected.ClientID, tc.ClientID, l.ClientID);} function doClick(val1, val2, val3, control1, control2, control3, control4)         {         &nbs

gridview and textbox changed event



i have a textbox changed event i am calling this event  when textbox  value changed.

this textbox is inside gridviews Itemtemplate

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowUpdating="Update_Schedule"
                    OnRowDeleting="Delete_Schedule" OnPageIndexChanging="OnPaging" OnRowEditing="Edit_Schedule"
                    OnRowCancelingEdit="CancelEdit" PageSize="10">
                                <asp:Label Text='<%# Eval("Title") %>' runat="server" ID="lbl1"></asp:Label>
                                <asp:TextBox ID="txtTitle" Text='<%# Eval("Title") %>' runat="server"></asp:TextBox>

GridView go to top of page when page is changed using bottom pager


I have a grid view where the user can change pages at either the top or the bottom of the grid view. 

I want the view to go back to the top whenever a user changes the page, whether they are changing from the top or the bottom.  I've tried using anchors and javascript to achieve this but it does not work.  The javascript is executed and the user is taken to the top of the gridview, this can be seen by placing an alert after the javascript to change the view.  But the last thing that happens on the page change is that the window is returned to it's previous position (the bottom of the page).  Is there any way of doing this?

How Get selected cell values from gridview


How Get particular selected cell value from gridview . my grid so many cell available..

i'm created dynamic row and cell ...

How to Retrieve the Hidden Cell value in GridView -- Urgent ************


Hello all,

In my GridView I have Hidden column contains ID. When User selects the rows and clicks on Delete Button( This is placed top of the Grid) Selected Rows will be deleted.

my delete button code is ...

foreach (GridViewRow dgi in Grid_Inbox.Rows){

CheckBox chkSelected = (CheckBox)dgi.FindControl("chk_Select");

if (chkSelected.Checked == true)


string strID = dgi.Cells[1].Text;

//Delete the Rows



//Binding the Grid



problem is when i am accessing through the code. getting cell value as bla

Gridview Cell Merging


Hi All,

I have a grid, where i need to do cell merging till certain columns. It is working and the code is as follows.

Friend Shared Sub GridviewCellMerge(ByRef gridViewControl As GridView, ByVal colStart As Integer, _
                                            ByVal colLast As Integer)
            For rowIndex As Integer = gridViewControl.Rows.Count - 2 To 0 Step -1
                Dim gvRow As GridViewRow = gridViewControl.Rows(rowIndex)
                Dim gvPreviousRow As GridViewRow = gridViewControl.Rows(rowIndex + 1)
                For cellCount As Integer = colStart To colLast
                    If gvRow.Cells(cellCount).Text = gvPreviousRow.Cells(cellCount).Text Then
                        If gvPreviousRow.Cells(cellCount).RowSpan < 2 Then
                            gvRow.Cells(cellCount).RowSpan = 2
                            gvRow.Cells(cellCount).RowSpan = gvPreviousRow.Cells(cellCount).RowSpan + 1
                        End If
                        gvPreviousRow.Cells(cellCount).Visible = False
                    End If
        End Sub

1. a  b  c  d

2. a  b  c  e

3. a  b  f  e

4. a  b  f  e

5. a  b  g 

Accessing gridview cell values


Hi All,

In my application Iam using GridView, in this there are fields (Quantity, Price, Amount) the user can enter Quantity Field value which is a template field (textbox). Iam calculating Amount(Quantity * Price) using Javascript and assigning to the Amount Column cells as below

Gridviewcell.innerText=Quanity * price.

and when user clicks on the Save button I want to add these details of Gridview to the database.

when I try to access the values of the gridview using below code

For i=0 to GridView.rows.count-1

GridView.Rows(i).Cells(2).toString ( for Example)

Next i

It is not displaying the changed value instead it is displaying the default value before calculating the amount.

Before implementing the Javascript part, I had done this in the code behind and it was working fine... Now I just dont want the page to get load so I used javascript.

Can any one help me out in able to access the value of Gridview cells which are assigned using Javascript.



changing Asp.net Gridview's cell from Label to edit mode in code behined file


 Hi all,

In my asp.net application i'm using gridview to which i'm binding data dynamically by writing a select query in code behined file (all column's are autogenerated) now i want to change gridview cell to edit mode from label to textbox or dropdown on clicking of gridview's cell.How can i achive this in code behined file.

thanks in advance

How to make a cell editable in gridview?


I was trying to create a gridview which should allow to edit a perticular cell on clicking on it. But is not working as expected. Here is my code. Can anyone tell whats the issue with this.

<Window x:Class="Window1"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib"
    Title="Window1" Height="279" Width="672">

        <Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}" >
            <Setter Property="Background" Value="#00ffffff" />
            <Setter Property="BorderBrush" Value="#00ffffff" />
            <Setter Property="Acce

How to log exactly what user has changed in Gridview event ?


I have Gridview which allows user to edit record.
I already build the event to save the new record, time and user machine information to a log database.
However, this means a whole record is saved to the log... if the user just change one or two column/field out of say 20 fields, then there is a lot of waste. Also the change is not obvious.

How can I log exactly which field(s) was changed in the record ?

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