Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Resizable Asp.net Gridview using jQuery with Example in C#, VB.NET

Sep 29, 2014
Introduction:

Here I will explain how to resize asp.net gridview using jQuery with example in c#vb.net or resizable gridview using jQuery with example. To implement resizable gridview using jQuery we need to use jQuery & jQuery ui plugin because we need to set
resizable() property for gridview to make it resizable in c#vb.net.

Description:


To implement this first create one new web application and open your Default.aspx and write the following code


<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Resizable Asp.net Gridview in jQuery with Example</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<script type="text/javascript">
$(function() {
$("#resizediv").resizable();
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="resizediv" class="ui-widget-content" style="width:300px; padding:0.3em">
<asp:GridView ID="gvDetails" CellPadding="5" runat="server" Width="100%" BorderStyle="Solid">
<HeaderStyle BackColor="#df5015" Font-Bold="true" ForeColor="White" />
</asp:GridView>
</div>
</form>
</body>
</html>
Now in code behind file write the code like as shown below

C# Code


using System;
using System.Data;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGridviewData();
        }
    }
    protected void BindGridviewData()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("UserId", typeof(Int32));
        dt.Columns.Add("UserName", typeof(string));
        dt.Columns.Add("Education", typeof(string));
        dt.Rows.Add(1, "Suresh Dasari", "B.Tech");
        dt.Rows.Add(2, "Rohini Dasari", "Msc");
        dt.Rows.Add(3, "Madhav Sai", "MS");
        dt.Rows.Add(4, "Praveen", "B.Tech");
        dt.Rows.Add(6, "Sateesh", "MD");
        dt.Rows.Add(7, "Mahesh Dasari", "B.Tech");
        dt.Rows.Add(8, "Mahendra", "CA");
        gvDetails.DataSource = dt;
        gvDetails.DataBind();
    }
}

VB.NET Code


Imports System.Data
Partial Class VBCode
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
            BindGridviewData()
        End If
    End Sub
    Protected Sub BindGridviewData()
        Dim dt As New DataTable()
        dt.Columns.Add("UserId", GetType(Int32))
        dt.Columns.Add("UserName", GetType(String))
        dt.Columns.Add("Education", GetType(String))
        dt.Rows.Add(1, "Suresh Dasari", "B.Tech")
        dt.Rows.Add(2, "Rohini Dasari", "Msc")
        dt.Rows.Add(3, "Madhav Sai", "MS")
        dt.Rows.Add(4, "Praveen", "B.Tech")
        dt.Rows.Add(6, "Sateesh", "MD")
        dt.Rows.Add(7, "Mahesh Dasari", "B.Tech")
        dt.Rows.Add(8, "Mahendra", "CA")
        gvDetails.DataSource = dt
        gvDetails.DataBind()
    End Sub
End Class

Now run above code and check the output that will be like as shown below

Output

Resizable asp.net gridview using jquery with example in c#, vb.net

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

1 comments :

sanju said...

Nice Article

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.