.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

Updating gridview attributes from javascript

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :ASP.Net
Hello,   I have been trying to use a custom attribute in my gridview to pass a comma delimited list of guids between my server-side and client side code.  Normally I would just use a hidden-field to do this, but I have to add a hidden-field into a row in my gridview to use one.  Since I need access to the updated value from javascript before my grid is rendered on postback, I can't use a control that is buried inside a row.  So instead, i was trying to add an attribute to the gridview and having the javascript update that value.   Here is the private property defined in my extended gridview class:  private List<Guid> _selectedValues { get { List<Guid> myList = new List<Guid>(); if (this.SelectionType != SOMgridviewSelectionType.None) { if (ViewState["SelectedValues"] != null) { return (List<Guid>)ViewState["SelectedValues"]; } } return myList; } set { if (this.SelectionType != SOMgridviewSelectionType.None) { if (string.IsNullOrEmpty(this.Attributes["hiddenSelectedValues&q

View Complete Post

More Related Resource Links

Ajax Enabled Gridview using JavaScript in ASP.NET

Before explaining the article, I would like to thank all readers who read my article and voted for it. Your appreciation for my article gives me strength to write more good articles. Hope in future I will get your valuable comments and suggestions. Now I won't waste your time and come back to the topic. I have written this article on 'Ajax Enabled Gridview Using JavaScript in ASP.NET'. In this article, I will show you how to make a Gridview using a simple HTML table, JavaScript and XML HTTP for Ajax call without using any ASP.NET control.

Using Code

GridView Javascript Click Row and Ajax

This article shows 2 common tasks with the ASP.NET GridView: Binding a List (generic) of objects as DataSource and on clicking a row, getting the values of the selected row by a javascript function. In the example a List with User-objects is displayed. On clicking a row containing the data of a User-object, the Id of the object is used to get the address of the user by an Ajax-call and display it in a details-field.

Select all checkboxes in gridview using Javascript


Hello members,


              I have used "Check box" inside the gridview...

              I need,

                           If i select the header check box , It should select all the checkbox inside the gridview...

              I have searched in google for this coding ...I got  lot of codes but couldn't get the correct code...

              I request anyone please provide me the correct code(using Javascript) thanks...

How To Access Datakeys In Javascript...and How To make gridview Column Visible true in javascript


How To Access Gridview's Datakeys In Javascript...and How To make gridview Column Visible true in javascript

Reply me..

validate the selection of atleast one checkbox in the gridview using javascript


 i have a gridview with a checkbox in the templatefield as given  below,

<asp:GridView runat="server" ID="gvAsgnHw"  AutoGenerateColumns="False"   >
        <asp:CheckBox id="cbAsgnHwGrid"   runat="server" /> </ItemTemplate></asp:TemplateField>

         <asp:BoundField DataField="Resource_id" HeaderText="Resource ID"/>
        <asp:BoundField DataField="Resource_name" HeaderText="Hardware Name" />

I want to check the selection of atleast one checkbox on a button click using javascript.
pls help

Calculating GridView total using JavaScript/JQuery


Hello everyone.

One month ago I've had very nice conversation with a asp.net forum member asking about issue regarding calculation of GridView textboxes total using JavaScript. The main thing was to allow user to manually write values in the text boxes (placed inside GridView column) and if the value has changed automatically to perform calculation on client side.

At the end of the conversation, we came up to two solutions. The first solution was using plain JavaScript, but since I thought it was not so robust, and in order to make it more robust we would need to write few more functions. Therefore, I have simply proposed another solution using JQuery which came up much better, more robust with less code.

In this blog post I will show both of the solutions and will provide step by step explanation on how we did that.

Note: I'm using VWD.

how do i use javascript to change values of controls inside a gridview

i have 2 labels (lblRate,lblTotal) and a textbox (txtQuantity) in a itemtemplate of a gridview.I want to calculate the products of rate and quantity and show it in Total as the textbox loses focus...i cant use textchanged because i dont want the page to postback.How do i use javascript to achieve this??Please Help Urgently....<asp:TemplateField HeaderText="Rate">                <ItemTemplate>                    <asp:Label ID="lblRate" runat="server" Text='<%# Eval("Rate") %>' />                </ItemTemplate>            </asp:TemplateField> <asp:TemplateField HeaderText="Quantity">                <ItemTemplate>                    <asp:TextBox ID="txtQty" runat="server" />                </ItemTemplate>&

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>

Validating DropdownList Inside Gridview Using Javascript

hi All,      I have Gridview with Dropdownlist which contains data as {select,1,2,3} .Gridview contains multiple rows of data.Submit button is also on form but outside gridview. If any of the rows of gridview dropdownlist contain value as "Select" and click Submit button ,give message as "Please select value". I want to do this stuff using javascript. Thanks in advance.

pass number of rows of Gridview to a javascript function

using vb.net/asp.net 2005.I need to pass the number of rows of the Gridview to a javascript function does anyone know how to do this?  thanks

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?

Adding user names when updating gridView

Hi All,May be this is a begineers question, could someone help on this please?I'm using a windwos authentication via intranet. I'm able to display the username in a label control on a page load event (which is very simple). I'm not storing this data anywhere in the table (MS SQL). I have all my data in a table and I'm using a gridview to diplay them. I'm using a button control to update all the rows in the gridview. I wanted to update three columns in the gridview (1. Tickbox, 2.Datetime Stamp and 3.UserId).I've created a query in the dataset, through which i can update the Tickbox and DateTime stamp using now() function. But I'm not sure how to update the UserID field with the UserName (which inturn updates all the three fields in the gridview when the button is pressed.

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


Hi all,

I'm trying to edit fields in my gridview, but for some reason it's not working. I've tested the sproc, and there's no apparent reason why it shouldn't work. When debugging the app and looking at e.Command.Parameters in both Updating and Updated (SqlDataSource), it only shows me the old values, which, to me, implies that this is the problem - it's not sending the updated values.

Anyone know how to fix this?

Cheers! :)

<asp:GridView ID="gvDisplayGroup" runat="server" AutoGenerateColumns="False" 
        <asp:BoundField DataField="RoleId" HeaderText="RoleId" 
            SortExpression="RoleId" ReadOnly="true" />
        <asp:BoundField DataField="RoleName" HeaderText="RoleName" 
            SortExpression="RoleName" />
        <asp:BoundField DataField="Description" HeaderText="Description" 
            SortExpression="Description" />
        <asp:BoundField DataField="role_level" HeaderText="role_level" 

GridView edit not updating



Can someone tell me where I have gone wrong? changing from VS2003 DataGrid to VS2010 GridView; still on SQL Server 2000 so the wizards for autogenerating the code are not compatible.

Delete works, RowUpdating does not. I get an ArgumentOutOfRangeException on "rowToUpdate("QuoteDQty") = Me.dgQuoteList.Rows(e.NewValues.Item(1).ToString)"

hide gridview column using javascript. working in ie and firefox but In firefox, gridview data is sh


function EnableDisableGridViewColumn() {
               var AdvanceSearch = document.getElementById('<%= chkboxlist1.ClientID %>');
               var chkList = AdvanceSearch.getElementsByTagName("input");
               var dgTest = document.getElementById("gridview1")
               if (dgTest != null)
                   for (var i = 1; i < dgTest.rows.length; i++) {

                       if (chkList[0].checked == true && chkList[1].checked == true) {
                           dgTest.rows[0].cells[0].style.display = "block";

Help:JAVASCRIPT (checkAll) & (Hide/Unhide GridView1) in a Datalist with a nested Gridview


Hey guys,

 I'm at my wits end on this one looked/Searched/Played/Experimented and I need your help if you can.

This page is going to be primarily used on a mobile device using Win Mobile 5


Need to Accomplish:

  1. Prevent Postback(serverside) of Page using JavaScript (Postback's slow down the page on mobile device)


JavaScript Requests:

  1. Hide and UnHide the Nested Gridview1 by Clicking on a imagebutton1 in DataList1icon_minized_collapse.pngicon_expand_collapse.png
  2. CheckBox in DataList1 Checks All and UNChecks All, CheckBox in just the related Gridview1


Controls :

  1. Gridview1 nested inside DataList1


Note: Datalist1 and Gridview1 have datasource's in production. The Codebehind page is just appling test data to help me figure this out.


Thank you all in advance for helping me with this.

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