Click here to Skip to main content
15,881,803 members
Everything / Gridview

Gridview

Gridview

Great Reads

by Herre Kuijpers
Extending the standard ASP.NET GridView control to add a vertical scrollbar in the grid
by OriginalGriff
When I add a log reader, the size of the log can be huge, and get very slow to view. This makes the GridView do all the work of paging the data for you.
by Don Hoang
This post describes implementing ASP.NET Gridview using Bootstrap 4.
by Razi Syed
Easily bind a class to .NET data controls like GridView, FormView, etc., and get an updated object or list back in the code-behind effortlessly.

Latest Articles

by Telegram:@ArastoAhmadi
Tutorial to monitor database changes without using tools and by using a simpler trick
by Herre Kuijpers
Extending the standard ASP.NET GridView control to add a vertical scrollbar in the grid
by Don Hoang
This post describes implementing ASP.NET Gridview using Bootstrap 4.
by SagSD
Bootstrap pagination for gridview with CSS only

All Articles

Sort by Score

Gridview 

7 Sep 2020 by Herre Kuijpers
Extending the standard ASP.NET GridView control to add a vertical scrollbar in the grid
8 Feb 2011 by OriginalGriff
When I add a log reader, the size of the log can be huge, and get very slow to view. This makes the GridView do all the work of paging the data for you.
30 Jul 2019 by Don Hoang
This post describes implementing ASP.NET Gridview using Bootstrap 4.
25 Apr 2012 by Razi Syed
Easily bind a class to .NET data controls like GridView, FormView, etc., and get an updated object or list back in the code-behind effortlessly.
21 Nov 2013 by ThatsAlok
TabHost control in MonoAndroid
2 Jul 2014 by Chakravarthi Elchuri
Display data in Multi nested gridview using C# in ASP.NET
29 Jan 2012 by Wonde Tadesse
I'm not sure what did you mean by "unbound value in Gridview", but one option to format fields in UI side will be to use DataFormatString property of BoundField[^]. For example
28 Jun 2012 by member60
suppose you are having two labels in gridview as : '> ...
14 Jul 2015 by ASP.NET Community
Learn how to extend your ASP.NET AJAX applications using the ASP.NET AJAX Control Toolkit. ASP.NET AJAX Control Toolkit: Installation and getting
13 Jul 2016 by Vincent Maverick Durano
A simple demo that explains how to do calculations in a GridView using JavaScript.
27 Jun 2012 by Technoses
The above code will slow down the browser and the browser can hang when Rows in Grid will be 10000 or above.Please view the below suggestion:CS Codeprotected void grvGroups_RowDataBound(object sender, GridViewRowEventArgs e){ if (e.Row.RowType == DataControlRowType.DataRow) { ...
9 May 2012 by Sandeep Mewara
As I thought, your code behind confirmed it that you indeed are exporting your grid.The above exception occurs when one tries to export a GridView control to Word, Excel, PDF, CSV or any other formats. Here the .net compiler thinks that the control is not added to the form and is rendered,...
5 May 2012 by Sandeep Mewara
To freeze Gridview header, try:Step 1:Create a CSS class as following.HeaderFreez{ position:relative ; top:expression(this.offsetParent.scrollTop); z-index: 10;}Step 2:Set Gridview's HeaderStyle CssClass as follows CssClass="HeaderFreez"
17 Dec 2012 by AshishChaudha
There are many scenarios in which the data can be bound in a Gridview, in which various operation other than provided by default by gridview needs to be implemented. In this article we will try to bind such operations with some more features.
17 Sep 2013 by TrushnaK
try this:-Use SessionParameter with SelectParameters to pass Session values" SelectCommand="SELECT * FROM [examConfig] WHERE [tchId]= @getTchId"> ...
30 Jul 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
We will explore the technique in jQuery to validate the ASP.NET GridView.
19 Mar 2010 by Mohd Arshad Malik
However, you did not provide your handler function which is used to update the data in grid... as you discussed in your question.My suggestion is, if you need to update or add data through a form or external interface (then grid), your approach to connect data through connected mode using...
15 Jan 2012 by Prasad_Kulkarni
Hi,Try this;How to add client side calculation in GridView[^]calculating-gridview-total-using-javascript-jquery[^]
29 Jan 2012 by Sergey Alexandrovich Kryukov
Please see the part of MSDN documentation of numeric format string: http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx[^].Locate the section "The Currency ("C") Format Specifier" and search by the keyword "currency" through all of this text for code samples, specification and related...
5 May 2012 by Mohamed Mitwalli
Hi , Check this Articles .Gridview with Fixed Header[^]Gridview Fixed Headers[^]http://geekswithblogs.net/thanigai/archive/2009/05/05/gridview-fixed-header.aspx[^]Best RegardsM.Mitwalli
21 May 2012 by Prasad_Kulkarni
Please refer:Export the Datatable records to Excel sheet in C#.net:Export to EXCEL from Datatable in C#.Net[^]Similar discussion: Click here[^]Export a DataTable to Excel in ASP.NET[^]Following link shows how to import or export DataTable to Excel or HTML files by using...
29 Jan 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Please follow the solution in How to validate textbox inside gridview to accept numeric values only[^].HTML:JAVASCRIPT://Restrict the user to key-in chrectors and other special...
10 Feb 2013 by Muthuraja Irullandi
Hi,Please see the below URLmerge gridview columns in asp.net[^]Best RegardsMuthuraja
5 Mar 2013 by willington.d
Hi KavithaleYou have to remove the '=' in the for loop. b'cos "i" value is starting from 0. for example, if u have 10 records in a gridview. you have to consider 0 to 9for (int i = 0; i
6 Sep 2013 by JayJanarthanan
View a twitter feed in the Windows 8 UI grid - the fast way
18 Sep 2013 by Prasad_Kulkarni
Try this: foreach (DataControlField col in gridView1.Columns) { if (col.HeaderText == "Name") { col.Visible = false; } }
8 Oct 2013 by Ron Beyer
Use the parse functions available in DateTime.DateTime.ParseExact(txtdate.Text, "dd/MM/yy", CultureInfo.InvariantCulture);DateTime.ParseExact[^]
10 Oct 2013 by Madhu Nair
Try this way - string Ques = ((TextBox)GridViewFRM.Rows[i].FindControl("GVQuestionTextBox")).Text;
17 Nov 2013 by Hazem Torab
Generate reasonable sample data for you GridView without using databases.
18 Dec 2013 by CPallini
Use the Path.GetFileName[^] method (see the sample code in the documentation page).
16 Jan 2014 by it.sudhiryadav
I am using gridView. I have some auto generated columns and some generated by me. Now the column which I have generated is displayed first and then the auto generated columns. I want to display auto generated columns first and then my generated columns.IMP Note 1 :- I can't use this (for...
16 Jan 2014 by Karthik_Mahalingam
HI Try like this..Consider your Gridview has two bound field columns as below set the AutoGenerateColumns as false
31 Jul 2014 by _Amy
Follow the steps:1. Add the footer templates to gridview(i.e. Textbox, Dropdown and ImageButton). .... 2. Assign the CommandName Property of ImageButton to "Add". .... 3. Handle...
1 Jul 2016 by Vincent Maverick Durano
A quick example on how to implement GridView row highlighting and retain selected row on postbacks.
2 Jul 2019 by phil.o
You cannot define a default value for an array as a parameter, because this way the default value has to be a compile-time constant. You can however test for a null value, and assign the default value accordingly: void MyMethod(string[] datakeyNames = null) { datakeyNames = datakeyNames ??...
2 Jul 2019 by #realJSOP
You can't do it with default parameters (for an array), but you can do it with an overload: public bool MyMethod() { string[] value = new string[] { "Id", "DataModified" }; return MyMethod(value); } public bool MyMethod(string[] value) { // do something with the string array ...
17 May 2010 by raju melveetilpurayil
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { CheckBox cbx = (CheckBox)e.Row.FindControl("checkBoxID"); if (cbx != null) { if (cbx.Checked) { e.Row.BackColor = System.Drawing.Color.Red; ...
6 Oct 2010 by Sunasara Imdadhusen
Hi,Please wirte inside the .aspx.cs pageprotected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton lbtnSetHidden = (LinkButton)e.Row.FindControl("lbtnSetValue"); ...
1 Nov 2010 by Mohd Wasif
For that u will have to create datatable and keep datatable in session .After entering all the required data save it in database .
3 Nov 2010 by Sunasara Imdadhusen
Hiadd following lines of code://Define global variabledt = (DataTable)Session["Address"];protected void btn1_click(object sender, EventArgs e) { if (dt.Rows.Count != 0) { if (dt.Columns.Count != 0) ...
18 Mar 2011 by That's Aragon
You can assign the href attribute dynamically. Something like below.if (e.Row.RowType == DataControlRowType.DataRow){//Condition for accessHtmlAnchor hreft = (HtmlAnchor)e.Row.FindControl("btnedit");if(IsUserLogin){hreft.HRef = assign URL}else{hreft.HRef =...
29 Mar 2011 by KimberlyKetchum
I have posted this question in a few other forums and have not gotten any replies. I have also tried searching online for an answer and have not been able to find one. Basically, I have a webpage where I display some account information in a gridview. The end user can sort the data by the...
13 Apr 2011 by Pong D. Panda
Google!http://msdn.microsoft.com/en-us/library/aa479350.aspx[^]
21 Apr 2011 by AeonBlue
I have a custom gridview with an export to excel feature, a column for edit/delete buttons in each row that is populated, and a footer that allows for new items to be added.Somthing a little like this: Showing 1-8 of 8 Results per page: 25 50...
23 Apr 2011 by Wonde Tadesse
Well, the easiest solution is to restrict the number of characters that are going to be displayed on each columns. So If the value that is going to be displayed greater that the fixed size say 50, then add additional control dynamically or make visible if exist and once you do that will show the...
3 Jul 2011 by Wonde Tadesse
Sure you can. But you need to be careful enough to do so. Because coding in design mode is not as convenient as server side code. For example'/>will calculate a...
17 Jul 2011 by thatraja
Try this which solved the OP's questionDynamically Assign Parameter to SqlDataSource Parameter Collection[^]
17 Jul 2011 by Abhinav S
This detailed article [^]should help you out.
1 Aug 2011 by Abhinav S
Tryhttp://csharpdotnetfreak.blogspot.com/2009/04/linkbutton-gridview-querystring.html[^]http://www.ezzylearning.com/tutorial.aspx?tid=5066444[^]http://www.asp.net/data-access/tutorials/adding-and-responding-to-buttons-to-a-gridview-cs[^]
15 Aug 2011 by senthil sennu
protected void Button_Click(object sender, EventArgs e){ foreach (GridViewRow itemrow in GridView1.Rows) { CheckBox cbview = (CheckBox)(itemrow.Cells[0].FindControl("viewdata")); if (cbview.Checked) { string value = GetObjectType(itemrow.Cells[2].Controls[1]); ...
2 Oct 2011 by André Kraak
Have a look at this: How to get Hidden Column Value in GridView[^].
7 Oct 2011 by genious Developer
FileStream stream = File.Open(filePath, FileMode.Open, FileAccess.Read);//1. Reading from a binary Excel file ('97-2003 format; *.xls)IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream);//...//2. Reading from a OpenXml Excel file (2007 format;...
10 Oct 2011 by André Kraak
As far as I could find there is not standard way to do this, you will need to subclass the DataGridView and take care of the painting yourself.You also need to set the background colour of all columns to transparent.See this SO answer: Set datagrid view background to transparent[^].As...
31 Oct 2011 by Måns Tånneryd
How to get WPF ListBox items with the same look-and-feel as items in a WPF ListView.
4 Nov 2011 by Abhinav S
Just use "*" in the width (instead of the hardcoded 900 value).Make the 300 width "Auto".Try
14 Nov 2011 by Mehul Harry
Hi Biradar,Could you please contact our support team here and they can help you find a solution for that?http://www.devexpress.com/Support/Center/CreateIssue.aspx?issuetype=Question[^]Thanks!-Mehul
20 Nov 2011 by Sunasara Imdadhusen
Hi,Please modify your code as per following:[+]" style="display:none">Note: this would only work if CourseCatID has Unique value.Thanks,Imndadhusen
20 Nov 2011 by Mehdi Gholam
I have found a possible solution here : http://www.dotnetmonster.com/Uwe/Forum.aspx/winform-data-binding/1042/BindingSource-Filter-fails-when-datasource-derives[^]
22 Dec 2011 by OriginalGriff
Instead of checking the Value of the field, check the field itself:If HdnSal.Value = Nothing ThenBecomes:If HdnSal Is Nothing OrElse HdnSal.Value Is Nothing Then
27 Dec 2011 by Sunasara Imdadhusen
Hiyou can use following code to show hide Hyperlink in gridview according to your condition.add DataKeyNames to your GridView ...
30 Dec 2011 by Sarvesh Kumar Gupta
Please use below code for adding a new row to gridDataTable _dtBands = ((DataTable)ViewState["Data"]).Clone(); DataRow row; if (_type == "ADD") { row = _dtBands.NewRow(); row["Item_ID"] = ""; row["Item_Name"] = ""; ...
6 Jan 2012 by Supriya Srivastav
Call a js function on OnClientClick event of button.e.g.if the button in gridview is like,
6 Jan 2012 by uspatel
you can use as ScriptManager.RegisterStartupScript( this, typeof(Page), "Alert", "alert('" + sMessage + "');", false);on button onclick event.
15 Jan 2012 by Anuja Pawar Indore
See this threadhttp://stackoverflow.com/questions/2522750/calculate-total-value-in-gridvew-in-asp-net-c-sharp[^]
1 Feb 2012 by Sridhar Patnayak
Look these links.Similar post:How to display rowspan and colspan in gridview[^]http://marss.co.ua/MergingGridViewHeaderColumns.aspx[^]ThanksSP
17 Feb 2012 by vonDy
i have a gridview and a textboxall i wanna do is a searching textbox that on each onkeyup the gridview contents changedi did this part althoughthe problem is when the page postback, the focus on textbox lost.And when i write code in code-behind as textbox.focus(), all the element...
21 Feb 2012 by Varun Sareen
You need to learn from the tutorials about ADO.Net:-http://www.csharp-station.com/Tutorials/AdoDotNet/Lesson01.aspx[^]Using ADO.NET for...
11 Apr 2012 by sravani.v
Refer these may give you some...
22 Apr 2012 by Mohamed Mitwalli
Hi Check this Example will Guide you protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString)) ...
20 May 2012 by vangapally Naveen Kumar
first you have to store excel data in datatable,you can store data in datatable asstring constring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MySpreadsheet.XLS;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=2"""datatable dt=new datatable();Oledbconnection con=new...
21 May 2012 by Abhinav S
Try DataSet to Excel File Conversion using ExcelLibrary[^].This discussion[^] might also be of some interest to you.
1 Jun 2012 by Prasad_Kulkarni
Please refer some links, you will surely get some reference to move on:Changing the color of a row in a GridView in ASP.NET[^]Change the GridView row color on click without postback[^]How to make a Gridview Row Color/ Cell Color/ Text Color[^]Similar discussion:Change the color of...
5 Jun 2012 by thatraja
Here couple of solutionsGridView - Show headers on empty data source[^]
22 Jun 2012 by Prasad_Kulkarni
Have you tried anything so far?At least a search on google..Always try google[^] first to get quick response, You can also search on CodeProject answers[^]Try first man, then post your questions here.
24 Jun 2012 by Prasad_Kulkarni
Refer:How to Fixed GridView's Header and Footer when scrolling?[^]Gridview with Fixed Header[^]Similar Threads:fix the header of gridview[^]gridview scroll with fixed header and footer[^]And don't forget CodeProject[^] search
28 Jun 2012 by Mohamed Mitwalli
Hi , Check this DateTime dt = new DateTime(); TimeSpan ts; protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { //here make your calculation by using TimeSpan . ...
10 Aug 2012 by csharpbd
hi, here an example i use "ProductInfo" class for GridView DataSource, "dtgView" my GridView and "lblPageInfo Label for display page information. You need to GridView AllowPaging="True" and generate OnPageIndexChanging="dtgView_PageIndexChanging" Event for paging your GridView. then need...
28 Aug 2012 by bhagirathimfs
These links may help youhttp://csharpdotnetfreak.blogspot.com/2012/06/sorting-gridview-columns-headers-aspnet.html[^]http://stackoverflow.com/questions/702600/sorting-and-paging-with-gridview-asp-net[^]
10 Sep 2012 by Sergey Alexandrovich Kryukov
Please see my comment to the question: of course this is possible and easy, but you need to clarify what is your image.If this is a bitmap, you usually use the class:...
1 Oct 2012 by Ahmed Mandur
Hi Mohammed ,I have made an example for you to make the functionality you are asking for here is the design as Screen http://i.imgur.com/yc4s5.jpg[^]then here is the code behind of the event Click of the button Add//Boolean to check if he has row has been bool...
26 Oct 2012 by adriancs
You can get data from Excel like database using System.Data.OleDb;using System.Data.OleDb;public DataSet ImportFromExcel(string file){ // Create new dataset DataSet ds = new DataSet(); // -- Start of Constructing OLEDB connection string to Excel file ...
16 Jan 2013 by __TR__
Lots of CP articles on this topic.Here are a few Insert, Update, Delete with Gridview ... Simple Way[^]Insert, Update, Delete in ASP.NET Gridview, DataSource as SQL Server, MS Access (mdb/accdb), XML and Framework as 2.0 / 3.0 / 3.5 / 4.0 (VS 2005/2008/2010)[^]GridView all in...
26 Feb 2013 by AshishChaudha
foreach(GridViewRow gvr in GridView1.Rows) { if (gvr.RowType == DataControlRowType.DataRow) { string value = ((DropDownList)gvr.FindControl("didDdl")).SelectedValue; //here write code for inserting in sql table.use parameterized query for...
12 Mar 2013 by Am Gayathri
Hi, I want to show one image inside my datatable. Am using code, dr = dt.newrow(); dr[0]= dt.addrow(dr);How can i do this?Here am checking some values, For example the value in any cell is greater than 50 the it should show one...
19 Mar 2013 by _Amy
Loop through GridView Rows. Try this:protected void btn_3id_Click(object sender, EventArgs e){ string str = ""; string srr = ""; foreach (GridViewRow row in GridView1.Rows) { if (((CheckBox)row.FindControl("CheckBox1")).Checked) { if (str ==...
25 Mar 2013 by Sergey Alexandrovich Kryukov
Don't mix up two different event arguments types used in different events: System.Web.UI.WebControls.GridViewUpdateEventArgs and System.Web.UI.WebControls.GridViewUpdatedEventArgs: first one does have RowIndex, and the second one does...
28 May 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
GridViewGridView Class[^].Quote:Displays the values of a data source in a table where each column represents a field and each row represents a record. The GridView control enables you to select, sort, and edit these items.Inheritance HierarchySystem.Object System.Web.UI.Control ...
12 Jun 2013 by yourfriendaks
try this... protected void grd_Distributor_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onmouseover", ...
10 Sep 2013 by Richard MacCutchan
https://www.google.com/search?...
25 Sep 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
ProblemIt is a typo mistake.SolutionThat is DataSource, not DataSoure.In your code "c" is missing.So. code will be like...protected void Gridview1_PageIndexChanging(object sender, GridViewPageEventArgs e){ GridView1.PageIndex = e.NewPageIndex; GridView1.DataSource =...
11 Oct 2013 by ASP.NET Community
The GridView control was introduced with ASP.NET 2.0 and Visual Studio 2005 as a replacement for the DataGrid control.  While it has many
11 Oct 2013 by ASP.NET Community
The question regarding how to check/uncheck CheckBoxes within a GridView control using JavaScript has been asked many times. Here is a quick
17 Oct 2013 by Javier Tirado Pampín
This article talks about how to solve the filter problem in Telerik MVC Extensions control suite
26 Oct 2013 by VICK
NOTE: not familiar with VB.. but you can use any of the online converter's to convert the example code in VB. or at least this will give you some idea.You can use Gridview's onRowDataBound event for this purpose.Get the Editbutton from specific row in this method as each row is bounded...
19 Nov 2013 by Sergey Alexandrovich Kryukov
This is how: http://api.jquery.com/last-child-selector/[^].It will help you to find a last row, which should be a element, and its parent element is either or :http://www.w3schools.com/html/html_tables.asp[^],http://www.w3schools.com/tags/tag_tbody.asp[^].The...
27 Nov 2013 by OriginalGriff
Numeric values do not have a "number of digits" which they remember. Only when you actually output them as strings to the user or a file can you specific exactly how they are displayed.There are a number of things wrong with your code:decimal temp= 6900 * ( 5 / 100);Is not "345.0000": it is...
15 Dec 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
The error message is quite clear.That means the StoredProcedure "DMLgrid_SP" is expecting parameter @id, but you are not sending that from code.So, do something like below to send the parameter.com.Parameters.AddWithValue("@id", someID);Also no need call ToString()...