Skip to main content

Posts

Showing posts with the label Gridview Solutions

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';"       ...

convert a boolean to Yes/No in a ASP.NET GridView

convert a boolean to Yes/No in a ASP.NET GridView   VB: <asp:TemplateField HeaderText = "Active" SortExpression = "Active" > <ItemTemplate>   <% #If(Boolean.Parse(Eval("Active").ToString()), "Yes", "No") %>   </ItemTemplate> </asp:TemplateField>    C#: <asp:TemplateField HeaderText = "Active" SortExpression = "Active" > <ItemTemplate>   <% # (Boolean.Parse(Eval("Active").ToString())) ? "Yes" : "No" %>   </ItemTemplate> </asp:TemplateField>