Skip to main content

Posts

Showing posts with the label Gridview

Total output in the GridView footer row

Total output in the GridView footer row //Global Declaration  Dim units22 as Integer=0 Dim units2 as Integer=0 //Grid Events Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound         If e.Row.RowType = DataControlRowType.DataRow Then             units22 = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Branches")) //Coloumn name             units2 = units22 + units2         End If         If e.Row.RowType = DataControlRowType.Footer Then             e.Row.Cells(6).Text = "Total"             e.Row.Cells(7).Text = units2.ToString().Trim()   ...

Display Confirmation Message on GridView Deleting

Display Confirmation Message on GridView Deleting This demo describes the different approach to display a confirmation message when deleting a row in GridView and pass the id of the item to the confirmation message. Confirmation means a user is asked first if he/she wanted to delete a record by choosing an option (OK and CANCEL). In this demo, we use the JavaScript confirm function for displaying the confirmation message. Now let’s create our JavaScript confirm function. To do this switch to ASPX source and add the following code block within the <head> tag like: < head runat ="server">     < title > GridView Data Manipulation </ title >     < script type ="text/javascript" language ="javascript">         function ConfirmOnDelete(item)         {           if (confirm( ...

Gridview row Selection

Gridview Row Selection  by any column VB: Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound         e.Row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(DirectCast(sender, System.Web.UI.Control), "Select$" + e.Row.RowIndex.ToString()))     End Sub       aspx: <%@ Page Language="VB" AutoEventWireup="false"  EnableEventValidation="false" CodeFile="GVEditonHighlight.aspx.vb" Inherits="sample_GVEditonHighlight" %>

Grid View Row Highlighting

Tip Of The Day - Remove Grid View Row Highlighting on Edit Mode Typically we will attach the mouseover and mouseout client-side events on the gridview rows to highlight rows on mouseover, but there are cases that we don't want to make the row highlighted when we are on edit mode. To do this we can check the GridView EditIndex to determine if the row is on edit mode and then do the validation there. Here's a sample code block below of what I am talking about:  VB : Protected Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs)         If e.Row.RowType = DataControlRowType.DataRow Then                Dim onmouseoverStyle As String =  "this.style.backgroundColor='blue';this.style.color ='white';"       ...

GridView Calculation with JavaScript

GridView Calculation with JavaScript In my previous post I wrote a simple demo on how to Calculate Totals in GridView and Display it in the Footer . Basically what it does is it calculates the total amount by typing into the TextBox and display the grand total in the footer of the GridView and basically it was a server side implemenation.  Many users in the forums are asking how to do the same thing without postbacks and how to calculate both amount and total amount together. In this post I will demonstrate how to do this using JavaScript. To get started let's go ahead and set up the form. Just for the simplicity of this demo I just set up the form like this: <asp:gridview ID="GridView1"   runat="server"   ShowFooter="true" AutoGenerateColumns="false">         <Columns>         <asp:BoundField DataField="RowNumber" HeaderText="Row Numb...