Posts

Showing posts with the label GridView

How to fetch data from Microsoft Dynamics CRM OnPremise and show them on Gridview with Search, Select, Paging and Sorting feature in Asp.Net, C#

Image
In this blog I am going to show how we can fetch data from Dynamics CRM OnPremise and Show them in a gridview on Web Page. Not only this but also following points: Selecting value of row by clicking anywhere on a row. Searching data in Gridview. Sorting of data in Gridview. Paging in Gridview. First of all take a Textbox for serach box and Gridview on your web page and place below code:: <form id="form1" runat="server">        <script type="text/javascript">        function RefreshParent(row) {          if (window.opener != null && !window.opener.closed) {              var message = "";              message += "Id: " + $("td", row).eq(0).html();              message += "\nName: " + $("td", row).eq(1).html();              alert(message);   ...

Create Nested Gridview with Expand and Collapse features in ASP.Net

Image
In this blog, I am going to show how we could create a nested gridview i.e gridview inside another gridview. The feature of this nested group is that the sub-grid will be hidden by default and when user clicks on "+" sign provided in Main gridview the subgrid will be shown to the user and "+" sign gets converted to "-" sign and again if user click "-" sign the subgrid gets hidden. The motive behind this is to show the detailed specification of particular record on click of button instead showing all records in a single grid. Additionally a small javascript has been used inside this code for attractive warning message, you may ignore that portion. First of all, add the below code inside the .aspx code window:: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="NestedGridview.aspx.cs" Inherits="NestedGridview" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ...

Search data in Gridview on Textbox Key press event using JQuery in Asp.Net- C#

Image
First of all add the following .js file, Link and the JavaScript to your <Head> tag :: <head runat="server">     <title></title>    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript" src="js/quicksearch.js"></script> <script type="text/javascript">     $(function () {         $('.search_textbox').each(function (i) {             $(this).quicksearch("[id*=gvDetails] tr:not(:has(th))", {                 'testQuery': function (query, txt, row) {                     return $(row).children(":eq(" + i + ")").text().toLowerCase().indexOf(que...

Selecting GridView Row by clicking anywhere on the Row in Asp.Net - C#

Image
In this blog I am going to how to show how to select GridView Row when mouse is clicked anywhere on the GridView Row in ASP.Net- C#   First of all add a page to your solution and add a gridview, a link button which will be used to render ASP.Net _doPostBack JavaScript as it requires for RowSelection. <head runat="server">     <title></title> <style type="text/css">     body     {         font-family: Arial;         font-size: 10pt;     }     td     {         cursor: pointer;     }     .hover_row     {         background-color: #A1DCF2;     } </style>  <script type="text/javascript">      $(function () {  ...

Bind image in gridview and Show image on Hover over specific column in GridView (Show image as ToolTip on Mouseover in GridView) in Asp.Net C#

Image
In this blog, I am going to show how to bind images in gridview and show this image on mouseover over any link/ image         Here, i have have shown how a image can be used as a tooltip in gridview. First of all, Write the below code in .aspx page and don't forgot to add "jquery.tooltip.min.js" and "jquery-1.8.2.js" to your solution. Just search it on google and you will get this .js file easily <%@ Page Language="C#" AutoEventWireup="true" CodeFile="GridViewToolTipaspx.aspx.cs" Inherits="GridViewToolTipaspx" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title>     <script src="http://code.jquery.com/jquery-1.8.2.js" type="text/javascript"></scri...

Code for Export data to excel, Sorting, Filtering and Paging GridView data in Aps.Net- c#

Place the whole code in .aspx page <%@ Page Language="C#" AutoEventWireup="true" CodeFile="NewGridTest.aspx.cs" Inherits="NewGridTest"  EnableEventValidation="false"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">    <div>         <div>             <asp:GridView ID="gvDetails" runat="server" AutoGenerateColumns="False"                 Font-Names="Verdana" AllowPaging="True" AlternatingRowStyle-BackColor="#EFF3FB" AllowSorting="True" PageSize="5" Width="40%"     ...

Code for Data Export from GridView to Excel in Asp.Net- c#

In this blog, I am going to show how we could export our data from a gridview to excel sheet in Asp.net- c# (Export to excel data) First of all, just take a gridview on your design page and fill data as below :: protected void Page_Load(object sender, EventArgs e)     {         if (!IsPostBack)         {            BindGrid();         }     }     protected void BindGrid()     {         gvDetails.DataSource = this.getData();         gvDetails.DataBind();     }     private DataTable getData()     {         DataTable dt = new DataTable();         dt.Columns.Add("UserId", ...

How to access different controls within the GridView control in Asp.Net(C#)

In this blog i am going to show you how to find different controls within the GridView control e.g. TextBox control, Button control, ListBox control, DropDown, etc. On the Button click event, I will print the values that are either entered (TextBox) or selected (DropDownList and ListBox). Let's see how this can be done :: protected void Button1_Click(object sender, EventArgs e) {     // Iterates through the rows of the GridView control     foreach (GridViewRow row in GridView1.Rows)     {         // Selects the text from the TextBox         // which is inside the GridView control         string textBoxText = ((TextBox)row.FindControl("TextBox1")).Text;         Response.Write(textBoxText);               // Selects the text from the DropDownList         // which is inside the GridView control     ...

How to show empty gridview when no data is available to display in Asp.Net- C#

Image
In this blog i am going to describe how we could add a custom message in GridView in Asp.Net(c#) in case data is not available in database/ datatable, etc. through code window (Although GridView provides direct property for this when data not available and users could use that property easily but in many case programmer wants to add message through code) First of all in the design page(.aspx) place a GridView control as: <div>         <asp:GridView ID="TestGrid" runat="server">         </asp:GridView> </div>  I used a very simple gridview without any styl& design, just to show message when data not available through code window. Now, in the code behind file(.aspx.cs) write the code as :: protected void Page_Load(object sender, EventArgs e)     {         if (!IsPostBack)         {             FillTestGrid(); ...

Add radio button control to Grid View and make only one selected radio button using JavaScript in Asp.net, C#

Image
In this blog, I am going to show how to add radio button to the gridview and only one radio button selection at a time using JavaScript. First of all, add the below javascript code inside your <head> tag which is responsible for only single readio button selected ::     <style type="text/css"> .Gridview { font-family:Verdana; font-size:10pt; font-weight:normal; color:black; width:300px; border-color:black; } </style> <script language="javascript" type="text/javascript">     function SelectSingleRadiobutton(rdbtnid) {         var rdBtn = document.getElementById(rdbtnid);         var rdBtnList = document.getElementsByTagName("input");         for (i = 0; i < rdBtnList.length; i++) {             if (rdBtnList[i].type == "radio" && rdBtnList[i].id != rdBtn.id) {                 rdBtn...
go to top image