Showing posts with label Gridview. Show all posts
Showing posts with label Gridview. Show all posts

Sunday, September 10, 2017

Get count of rows and columns from datatable in asp.net

In this article I am going how to get count of rows and columns from datatable in asp.net.

Implementation:
I want to know how many rows and columns in datatable or dataset?

Syntax
C# code

int row = dt.Rows.Count;
int column = dt.Columns.Count;
//dataset row count
  int row = ds.Tables[0].Rows.Count;
  int column = ds.Tables[0].Columns.Count;

VB.net code

Dim row As Integer = dt.Rows.Count
Dim column As Integer = dt.Columns.Count
dataset row count
Dim row As Integer = ds.Tables(0).Rows.Count
Dim column As Integer = ds.Tables(0).Columns.Count

Example:
HTML Markup of webform

Saturday, September 9, 2017

Asp.net Gridview : Replace null or empty value with default message

In this article I am going to explain how to replace null or empty value with default message such as “-NA-“or “Data not available” in asp.net Gridview.

Description:
I am showing list of Employees in gridview data control. Some of columns are empty. I want to show a default message “-NA-“instead of empty column.

  
Implementation:

Wednesday, September 6, 2017

Different approaches to change Gridview row color on mousehover in asp.net

In this article I am going to explain different approaches to change Gridview row color on mousehover in asp.net.

Description:
I am showing employees detail in Gridview data control. I want to change the color of row on mousehover.


Implementation:
We have many approaches to change the row color on mousehover code behind, through CSS and javascript.

HTML Markup of webform:

Sunday, September 3, 2017

Asp.net Gridview: Change row color on mousehover

In this article I am going to explain how to change Gridview row color on mousehover in asp.net.

Description:
I am showing employees detail in Gridview data control. I want to change the color of row on mousehover.


Implementation:
We have many approaches to change the row color on mousehover code behind, through CSS and javascript.

HTML Markup of webform:

Saturday, August 19, 2017

Asp.net : Display tooltip in Gridview column on mouseover

In this article I am going to explain how to display tooltip in Gridview column on mouseover in asp.net. 

Description:
I am displaying employee’s information in Gridview and want to display each column data when placed mouse on column. We have 2 options 1st write  code on RowDataBound event of Gridview and 2nd use the label control’s tooltip property.

Implementation:
Method 1:

Complete source of webform

Friday, August 18, 2017

How to show tooltip on entire Gridview row hover in asp.net

In this article I am going to explain how to show tooltip on entire Gridview row mouse hover in asp.net.


Description:
I am displaying employees information in Gridview and want to display name & phone no. when mouse is hovered on row. To fulfill this requirement we have write code on RowDataBound event of Gridview.

Implementation: 

Complete source of webform

Tuesday, August 15, 2017

How to Freeze Gridview’s (Scrollable) column and header using Jquery in asp.net

In this article I am going to explain how to freeze Gridview’s (Scrollable) column and header using Jquery in asp.net.

Description:
I have populate the gridview with employee’s information. I want to freeze the first column (name of employee) and header of Gridview (Scrollable). I am using GridviewScroll Jquery to implement this.

Implementation:
Complete Source of Webform

Sunday, August 13, 2017

Freeze columns of Gridview in asp.net

In this article I am going to explain how to freeze the columns of Gridview in asp.net.

Description:
I have populate the gridview with employee’s information. I want to freeze the first column (name of employee) of Gridview. I am using GridviewScroll Jquery to implement this.

Implementation:

Complete Source of Webform

Friday, July 21, 2017

Asp.net Gridview : Merge two or more fields together

In this article I am going to explain how to merge two or more fields together (concatenate) in Asp.net Gridview.
.
Description:
I want to show two or more fields together (concatenate). We can do this in Itemtemplate. It is not possible to concatenate fields in boundfiled. If want to show concatenate fields in Boundfield, then you have to concatenate fields in sql store procedure.

Implementations:
I have created a table users and insert some dummy records into it.

Asp.net Gridview : Merge two or more fields together

Asp.net Gridview : Merge two or more fields together


I want to concatenate First and last together.

HTML Markup of Webform:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:GridView ID="grdusers" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333" GridLines="None">
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
            <Columns>
                <asp:TemplateField HeaderText="Name">
                 <ItemTemplate>
                     <asp:Label ID="Label1" runat="server" Text='<%# Eval("Firstname")+" "+Eval("Lastname") %>' ToolTip='<%# Eval("Firstname")+" "+Eval("Lastname") %>'></asp:Label>
                 </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Name">
                 <ItemTemplate>
                        <%# Eval("Firstname") %> <%# Eval("Lastname") %>
                      </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <EditRowStyle BackColor="#999999" />
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
            <SortedAscendingCellStyle BackColor="#E9E7E2" />
            <SortedAscendingHeaderStyle BackColor="#506C8C" />
            <SortedDescendingCellStyle BackColor="#FFFDF8" />
            <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
        </asp:GridView>
    </div>
    </form>
</body>
</html> 

Wednesday, July 19, 2017

Asp.net Gridview : Replace NULL or Empty values with other/message text

In this article I am going to explain how to replace NULL or Empty values with other/message text in Asp.net Gridview.
.
Description:

When we are displaying records in Gridview, some of fields have null value.  I want to show -–NA—on the instead of empty column. We have 2 options to achieve this. If we are using Boundfield in that case we can use NullDisplayText property.
2nd option to write the code on RowDatabound event of Gridview.

Tuesday, July 18, 2017

How to set DateTime format in Gridview

In this article I am going to explain how to set DateTime format in Gridview’s Boundfiled and Template field column.

Description:
In some application we don’t want to show complete date time. In some application we have to show only date or in some cases date with time in different formats. We have DataFormatString options to set date and time.

Sunday, May 8, 2016

Displays file icons in asp.net

In this article I am going to explain how to display file icons according to file extensions in asp.net


Description:
I have created a table Tb_File and insert some dummy record. I am displaying the record in gridview data control. I want to display filename with file icons according to file type. Let us create a demonstration to implement this concept.

Implementation:

Saturday, May 7, 2016

Asp.net Gridview sorting example using jquery

In this article I am going to explain how to do sorting in gridview data control using Jquery.

Asp.net Gridview sorting example using jquery
In the previous article I have explained how to validate the email address of users in MVC application using Data Annotation, how to filter record in MVC Webgrid based on textbox and how to apply or set the custom style on MVC webgrid.

Description:
We have three ways to implement this functionality: Jquery, Sql datasource and code behind. Here in this tutorial I am going to use Jquery plugin Tablesorter. Go to website of  Tablesorter Jquery plugin and download the latest version.


Implementation:

Create Store procedure to get data

Thursday, May 5, 2016

Open (view) all type of files with associate program in asp.net using C#, VB.net

In this article I am going to explain how to open (view) all type of files (images, word document, excel, PDF etc.) with associate program in asp.net using C#, VB.net.

Open (view) all type of files with associate program in asp.net using C#, VB.net


Description:

Wednesday, May 4, 2016

How to display image icons according to file extensions in asp.net

In this article I am going to explain how to display image icons according to file extensions in asp.net

How to display image icons according to file extensions in asp.net

Description:
I have created a table Tb_File and insert some dummy record. I am displaying the record in gridview data control. I want to display filename with file icons according to file type. Let us create a demonstration to implement this concept.

Implementation:

Tuesday, May 3, 2016

Asp.net Gridview sorting example in ascending and descending order code behind

In this article I am going to explain how to do sorting in gridview data control by column header in ascending and descending order code behind.

Asp.net Gridview sorting example in ascending and descending order code behind

Description:
We have three ways to implement this functionality: Jquery, Sql datasource and code behind. Here in this tutorial I am going to implement using code behind.



Implementation:

Tuesday, April 12, 2016

Add row in asp.net Gridview on button click using C# and vb.net

In this article I am going to explain how to add a row in gridview to insert the record into database on add new button click in asp.net.
Add row in asp.net Gridview on button click using C# and vb.net
Add row in asp.net Gridview on button click using C# and vb.net


Description: