Saturday, June 27, 2015

How to apply pagin and sorting in gridview in asp.net

For applying paging and shorting follow some steps.
Step No -

First we will create a database Demodatabase.
Now create table Demo.

3. Now I am going for design part<%@ Page Language="C#" AutoEventWireup="true" CodeFile="gridview_controls.aspx.cs" Inherits="gridview_controls" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <div style="font-size: 20px; font-family: Verdana"> <u> Gridview Paging and Sorting</u> <br /> <br /> </div> <div> <asp:GridView ID="GridVwPagingSorting" runat="server" AutoGenerateColumns="False" Font-Names="Verdana" AllowPaging="True" AllowSorting="True" PageSize="5" Width="75%" OnPageIndexChanging="PageIndexChanging" BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" OnSorting="Sorting" BackColor="White" CellPadding="4" GridLines="Horizontal"> <PagerStyle BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" BackColor="#336666" ForeColor="White" HorizontalAlign="Center" /> <FooterStyle BackColor="White" ForeColor="#333333" /> <HeaderStyle Height="30px" BackColor="#336666" Font-Size="15px" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" Font-Bold="True" ForeColor="White" /> <RowStyle Height="20px" Font-Size="13px" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" BackColor="White" ForeColor="#333333" /> <Columns> <asp:BoundField DataField="Emp_id" HeaderText="ID" SortExpression="Emp_id" /> <asp:BoundField DataField="Emp_Name" HeaderText="Name" SortExpression="Emp_Name" /> <asp:BoundField DataField="Emp_job" HeaderText="Title" SortExpression="Emp_job" /> <asp:BoundField DataField="Emp_Dep" HeaderText="Department" SortExpression="Emp_Dep" /> </Columns> <SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" /> <SortedAscendingCellStyle BackColor="#F7F7F7" /> <SortedAscendingHeaderStyle BackColor="#487575" /> <SortedDescendingCellStyle BackColor="#E5E5E5" /> <SortedDescendingHeaderStyle BackColor="#275353" /> </asp:GridView> </div> <div style="color: Green; font-weight: bold"> <br /> <i>You are viewing page <%=GridVwPagingSorting.PageIndex + 1%> of <%=GridVwPagingSorting.PageCount%> </i> </div> </div> </form> </body> </html>



4. Code behindusing System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Web.UI.WebControls; public partial class gridview_controls : System.Web.UI.Page { string Sort_Direction = "Emp_Name ASC"; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ViewState["SortExpr"] = Sort_Direction; DataView dvEmployee = Getdata(); GridVwPagingSorting.DataSource = dvEmployee; GridVwPagingSorting.DataBind(); } } private DataView Getdata() { using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString())) { DataSet dsEmployee = new DataSet(); string strSelectCmd = "SELECT * FROM employee"; SqlDataAdapter da = new SqlDataAdapter(strSelectCmd, conn); da.Fill(dsEmployee, "Employee"); DataView dvEmp = dsEmployee.Tables["Employee"].DefaultView; dvEmp.Sort = ViewState["SortExpr"].ToString(); return dvEmp; } } protected void PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e) { GridVwPagingSorting.PageIndex = e.NewPageIndex; DataView dvEmployee = Getdata(); GridVwPagingSorting.DataSource = dvEmployee; GridVwPagingSorting.DataBind(); } protected void Sorting(object sender, System.Web.UI.WebControls.GridViewSortEventArgs e) { string[] SortOrder = ViewState["SortExpr"].ToString().Split(' '); if (SortOrder[0] == e.SortExpression) { if (SortOrder[1] == "ASC") { ViewState["SortExpr"] = e.SortExpression + " " + "DESC"; } else { ViewState["SortExpr"] = e.SortExpression + " " + "ASC"; } } else { ViewState["SortExpr"] = e.SortExpression + " " + "ASC"; } GridVwPagingSorting.DataSource = Getdata(); GridVwPagingSorting.DataBind(); } }
5. Now Debug


What do you think ?


Give me feedback by comment.


I hope it is helpfull for you.

How to bind Grid List on select on changed dropdrown list .

We need to follow this steps
Step - 1
public ActionResult Index()
{
    ViewBag.ProjectCategory = db.DNS_ProjectCategory.ToList();
     return View();
}
public ActionResult ProjectListByCategory(string CategoryID = "")
{

if (CategoryID != "")

{

var lstProject = (from m in db.DNS_Projects where m.ProjectCategory == CategoryID select m).ToList();

return PartialView("ProjectListByCategory", lstProject);

}

else

{

var lstProject = (from m in db.DNS_Projects select m).ToList();

return PartialView("ProjectListByCategory", lstProject);

}

}





Step - 2 PartialView





@model IEnumerable<SocialLikeGroups.Models.EntityModel.DNS_Projects>

<style>

hr {

-moz-border-bottom-colors: none;

-moz-border-image: none;

-moz-border-left-colors: none;

-moz-border-right-colors: none;

-moz-border-top-colors: none;

border-color: #EEEEEE -moz-use-text-color #FFFFFF;

border-style: solid none;

border-width: 1px 0;

margin: 18px 0;

}


.RightAlign {

width: 100%;

text-align: right;

}

</style>

<div class="RightAlign">

<a href='@Url.Action("Create", "Project")' class="btn btn-success">AddNew Project</a>

</div>

<hr />


<div class="panel panel-primary">

<div class="panel-heading">

<h3 class="panel-title"><i class="fa fa-bar-chart-o"></i> Project List</h3>

</div>

<div class="panel-body">

<div id="shieldui-grid1">

<table>

<tr>

<th>

ID

</th>

<th>

@Html.DisplayNameFor(model => model.ProjectName)

</th>


<th>

@Html.DisplayNameFor(model => model.ProjectURL)

</th>


<th>

@Html.DisplayNameFor(model => model.ProjectCategory)

</th>

<th>Online</th>

<th>Edit</th>

<th>Details</th>

<th>Delete</th>

</tr>


@foreach (var item in Model)

{

<tr>

<td>

@Html.DisplayFor(modelItem => item.ProjectID)

</td>

<td>

@Html.DisplayFor(modelItem => item.ProjectName)

</td>


<td>

@Html.DisplayFor(modelItem => item.ProjectURL)

</td>


<td>

@Html.DisplayFor(modelItem => item.ProjectCategory)

</td>

<td><a class="btn btn-success" href="@item.ProjectURL" target="_blank">Online</a></td>

<td>

<a href='@Url.Action("Edit", "Project", new { id = item.ProjectID})' class="btn btn-success">Edit</a>





</td>

<td>

<a href='@Url.Action("Details", "Project", new { id = item.ProjectID})' class="btn btn-success">Details</a>





</td>

<td>


<a href='@Url.Action("Delete", "Project", new { id = item.ProjectID })' class="btn btn-success">Delete</a>

</td>

</tr>

}


</table>

</div>

</div>

</div>




Step - 3 Main Index Action with view





@model SocialLikeGroups.Models.EntityModel.DNS_Projects

@{

Layout = "~/Views/Shared/_Layout.cshtml";

}


@using (Html.BeginForm())

{

<div>

<div class="col-md-9">

@Html.DropDownListFor(model => model.ProjectCategory, new SelectList(ViewBag.ProjectCategory as System.Collections.IEnumerable, "Name", "Name", new { @class = "form-control"}), new { id = "DDLProjectCategory" })

</div>

</div>

<hr />

<div id="dialog"></div>

}

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>


<script type="text/javascript">

$("#ShowDiv").show();

$("#DDLProjectCategory").change(function ()

{

var ID = $(this).val();

$.ajax({

type: "Post",

url: '@Url.Action("ProjectListByCategory", "Project")',

data: { CategoryID: ID },

dataType: "html",

success: function (data)

{

alert(data);

$("#ShowDiv").hide();

$('#dialog').html(data);

},

error: function (req, status, error)

{

alert(error);

}

});

})

</script>

<div id="ShowDiv">

@Html.Action("ProjectListByCategory", "Project")

</div>

I think It is helpful for you.

Sunday, June 21, 2015

Introduction of DotNetNuke ?

DotNetNuke is a web content management system base on Michrosoft .NET. The Community Edition is open source DotnetNuke was written in VB.NET, though the developer has shifted to C# since version 6.0.”

What is DotNetNuke ?
DotnetNuke is an open source based on Microsoft .Net Technology. DotnetNuke can be easily installed and hosted. In genral, dotnetnuke framework allows individuals to do whatever they wish with the application framework both commercially and non-commercially, with the simple requirement of giving credit back to the dotnetnuke project community.
 
 
What is dotnetnuke used for ? 
DotnetNuke framework is ideal for creating a broad range of commercial portal applications that allows administrators to work effectively with add-ons, third party assemblies, and custom tools,. The dotnetnuke technology is essentially designed to ease the work of administrators, content editors, developers, and designers.
 
 
What is dotnetnuke skin? 
DNN Skins allows those who are not so skilled at design to create a good looking. DNN modules and skins are easy to find, purchase, or build and operate. Just choose the required skin from a list of skins and the whole website is updated to the new look.
 
 
What is dotnetnuke framework ? 
DotnetNuke is a Web Application Framework that provides a highly extensible development environment based on publishe standards and proven design patterns.
 
I hope, It is helpfull for you.

Rewrite whole Web Site System and Sub System with data migration to new system.

Can you please share me your skype id or whats up number for better communications  my skype id is - jitendra.tech  whats up - +919617741414...