Related Posts Plugin for WordPress, Blogger...

About

Follow Us

Showing posts with label GridView. Show all posts
Showing posts with label GridView. Show all posts

Wednesday, 5 August 2015

In this article I will explain how to add, update and delete data in gridview. I will use Row_Command Event to do all these tasks. Follow the given steps:

In this article I will explain how to insert data to database using gridview. We can insert data to database from gridview control.  I will insert data on Row_Command Event of gridview.

Tuesday, 28 July 2015

In this article I will explain how to display data in gridview  using SqlDataSource. Here I will explain how to bind grid with sqldataSource and show data in gridview without doing any code.

Monday, 27 July 2015

In this article I will explain How to edit, update and delete data from xml through gridview. I will bind gridview to xml file, then update and delete data from it.

Friday, 3 July 2015

Introduction
In this article I will explain how to implement paging in gridview. Paging is very much helpful in case of large data. If data is large then it is not user friendly to show whole in one time. In this case we will use paging. It is very easy to implement Paging in gridview.

Implementation:

Design page:

Tuesday, 2 June 2015

Introduction: 

In this Article I will explain how to create datatable dynamically and bind that datatable to gridview in asp.net using c# and vb.net.

Tuesday, 14 April 2015

Introduction:
Sometime it is need to export data to excel from gridview or datatable. We can export data through code in asp.net (using C# & vb.net).


Introduction: 

In this Article I will explain how to show or display sum of columns total in gridview footer using asp.net in c#, vb.net.

Monday, 13 April 2015

Introduction: 

Paging in gridview is very important concept in case of large data. If data is large, it is not possible to show data in single page. So in that case we will use paging to break data in no of pages. Pageindexchanging event of gridview is used for paging.
Introduction:

In this article I will explain n how to set gridview column width in Asp.Net dynamically using c# and vb.net. There are many methods by using them we can set width dynamically.
I have discussed three methods:

Method 1:

In case we are using Bound Fields (set  AutoGenerateColumns="false")  then we can set the columns width by using ItemStyle-Width property like as shown below

<asp:GridView runat="server" ID="gvrecords"  AutoGenerateColumns="false"
HeaderStyle-BackColor="#7779AF" HeaderStyle-ForeColor="White" >
<Columns>
<asp:BoundField DataField="UserName" HeaderText="UserName" ItemStyle-Width="50px" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName" ItemStyle-Width="50px" />
<asp:BoundField DataField="LastName" HeaderText="LastName"  ItemStyle-Width="50px" />
<asp:BoundField DataField="Location" HeaderText="Location" ItemStyle-Width="50px" />
</Columns>
</asp:GridView>

Method 2:

If we binding columns dynamically then we can set width of columns dynamically by using following code:
C# Code

protected void GrdView_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)
{
grdListings.Columns[1].ItemStyle.Width = 50;
grdListings.Columns[2].ItemStyle.Width = 150;
}
}

VB.NET Code

Protected Sub GrdView_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
grdListings.Columns(1).ItemStyle.Width = 50
grdListings.Columns(2).ItemStyle.Width = 150
End If
End Sub

Method 3:

Third method is using CSS. Using CSS we can set width of the columns:
<style type="text/css">
.columnscss
{
width:150px;
font-weight:bold;
font-family:Verdana;
}
</style>

Once we create css class in aspx then we need to write the following code in code behind

C# Code

protected void GrdView_RowDataBound(object sender, GridViewRowEventArgs e)
{

if (e.Row.RowType == DataControlRowType.DataRow)
{
for (int i = 0; i > e.Row.Cells.Count; i++)
{
e.Row.Cells[i].CssClass = "columnscss";
}
}
}

VB.NET Code

Protected Sub GrdView_RowDataBound(sender As Object, e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim i As Integer = 0
While i > e.Row.Cells.Count
e.Row.Cells(i).CssClass = "columnscss"
i += 1
End While
End If
End Sub

Wednesday, 8 April 2015

Introduction: 

In this article I will explain how to save or upload word document files into SQL Server database and download files from database in asp.net.