Click here to Skip to main content
15,890,438 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 Updated

Gridview 

15 Jan 2024 by softotal
Thank you i found the solution I was using the event DoubleCLick but in stead i have to use the event CellMouseDoubleClick Thank you so much, much appreciated
15 Jan 2024 by softotal
I have a Datagrid that gets rows from a database table. I wrote code to populate a textbox when double clicking a row. If I doubleclick a row all is ok and no errors but if i doubleclick the area below the last row it gives me an error. This is...
14 Jan 2024 by OriginalGriff
This is not a good question - we cannot work out from that little what you are trying to do. Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for...
19 Jun 2023 by Magic Wonder
Dear All, As mentioned in subject, I am using GridView in my page. It was working till the time I have unsafe-inline mentioned in content security policy. However, now same has to remove due to security issues. After removing it,...
19 Jun 2023 by Richard Deeming
The problem is that you're using WebForms - a framework which was last updated at least a decade before the first CSP specification. WebForms emits a buttload of inline scripts, many of which are dynamically generated so you can't add their...
14 Jun 2023 by miss786
I would like to know, if it is possible to add multiple data fields to the hyperlink control, in order to create querystring (URL). I attempted below sing EVAL but this property only takes into account 2 arguments. Is there another way to do this, if so, please advice further. ...
16 Apr 2023 by Mike Radunski
I have a gridview: ' runat="server"> ...
16 Apr 2023 by Richard Deeming
You need to set the control's ClientIDMode property[^] to Static. Otherwise, the actual ID rendered in the HTML will be "mangled" with a combination of the IDs of its ancestors.
14 Mar 2023 by Graeme Perrins
I have a Flutter scrolling GridView builder that looks like it renders the ListTiles below the Container the GridView is placed in. It appears it renders placeholder grid list tiles even when they are not within the Container bounds. It looks...
8 Mar 2023 by Mike Radunski
Hi, now at school we are learning how to use GridView. We have a table with all the information of all the users. When we want to update a row, we need to store name, last name and other data in separate variables. Our teacher does it this way: ...
8 Mar 2023 by Richard MacCutchan
GridViewRow changedRow = GridView1.Rows[e.RowIndex]; string firstName = ((TextBox)changedRow.Cells[1].Controls[0]).Text; changedRow : select the row in GridView1 at the offset in e.RowIndex Select the control at changedRow.Cells[1].Controls[0]....
6 Mar 2023 by ahmed_sa
I work on asp.net web forms . I face issue I can't display previous and next button with Numeric page number . current status display page number numeric mode only as 1,2,3,4 etc. but I can't display previous and next with page numbers so How...
27 Feb 2023 by kimkyie
I use gridview in my webpage to do calculation then I add checkbox in datatable but the main problem is I don't have any error when I debug but my calculation in table didn't work. Before I added checkbox the calculation works perfectly. How to...
27 Feb 2023 by Graeme_Grant
Take a look at this article here on CodeProject: How To: Do Calculations in GridView[^] or this one: Calculate ASP.Net GridView Running and Grand Total using JavaScript[^]. I found these using this search: asp.net webform gridview calculated...
16 Jan 2023 by Cruz Vince
Is there any way to save the checkmarks in the checkbox of gridview in devexpress? Whenever I close and reopen my application, the checkboxes is left uncheck again. What I have tried: I haven't tried anything yet, just did the MultiSelectMode...
16 Jan 2023 by CHill60
AFAIK there is no way it will "just happen" - but you can put code into to make sure the settings are saved - try one of these articles Codeproject articles on saving settings[^]
21 Nov 2022 by Kuepo David giress
string Users = "select UserId from Users where Name=" + User.Identity.Name; What I have tried: Actually all solution who i try don't not succes
21 Nov 2022 by OriginalGriff
You don't put data into a DB with a SELECT statement - that fetches data from the DB. To add new data, you use an INSERT: SQL INSERT INTO Statement[^] To change existing data, you use an UPDATE: SQL UPDATE Statement[^] Either way, you need to...
20 Nov 2022 by Kuepo David giress
protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataTable dt = new DataTable(); dt = (DataTable)Gridview1.DataSource; ...
8 Sep 2022 by Telegram:@ArastoAhmadi
Tutorial to monitor database changes without using tools and by using a simpler trick
16 Jun 2022 by Thirumadhi T Johnson
Is there any way where I can autofill date like I have two columns in gridview both the columns are dateformat(MM/dd/yyyy) now if in column effective date I entered 12/01/2020 and than next column Expiry date should show populate 1 year greather...
16 Jun 2022 by OriginalGriff
I'd probably do it at the source level: when you retrieve the data to enter, generate the "extra data" then. For example, if your data comes from SQL: SELECT MyDateColumn, DATEADD(yy, 1, MyDateColumn) AS OneYearOn FROM MyTable Would give you the...
16 Jun 2022 by RickZeeland
See answer here: Get value of cell based on another cell from datagridview[^]
16 Jun 2022 by Thirumadhi T Johnson
Hi Folks Another issue I have as I am working on winform task where I have 5 columns and 1st column is for checkbox .The issue is here If there are more than 10 rows/records than I am unable to select checkbox properly it just moves up and down...
16 Jun 2022 by RickZeeland
Change: else row.Selected = false; BtnCancel.Enabled = true; btnUpdate.Enabled = true; btnDelete.Enabled = true; Into: else { ...
16 Jun 2022 by OriginalGriff
Without your data and your code running as you have it, we can't really tell when is going on at all. So, it's going to be up to you. Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If...
14 Jun 2022 by Fydobas
You could actually do this in a much simpler way; you could simply loop through the DataGridView's rows and iterate an integer variable every time you find a row which value for the field in question is equivalent to 1 (or larger than zero, for...
14 Jun 2022 by Thirumadhi T Johnson
Below code is if checkbox selection will check with count and it is more than 1 than it will call update method or else it shows message box as "Please select at least one check box".But if after selection checkbox too no values has been edited...
13 Jun 2022 by Thirumadhi T Johnson
I have 6 columns contain one gridview where in 3rd column I would like to allow only numbers no other special or junk characters . What I have tried: private void dataGridView1_EditingControlShowing(object sender,...
13 Jun 2022 by RickZeeland
See answers here: Limit entry of only digits in a DataGridView column[^]
13 Jun 2022 by Thirumadhi T Johnson
I would like to throw a validation message if after selecting checkbox in gridview if there is no value edited/changed in any cells than after clicking update button it should stay on same page and throw a validation message .Please help me how...
13 Jun 2022 by ludosoep
It can be done like this. When reading you could store the value in both the cell.Value and cell.Tag property. When the cell.Value changes you can detect it by comparing it to the cell.Tag. Then when you successfully store the input data, you can...
24 May 2022 by mathew_ronu
Dear, I am working on a project where I need to fetch "Id" from a stored procedure as a checkbox and pass the value to Grid view. The code below is working fine if i select a single checkbox. but when i select multiple it will only show me the...
24 May 2022 by Richard Deeming
The CheckBoxList1.SelectedItem property will return either the first selected item, or null if no items are selected. Thus if you select multiple items, you will only ever display the details for the first selected item. And if you deselect all...
10 May 2022 by Herman<T>.Instance
Hi All, recently I started a discussion about loading data in GridView component. Richard Deeming pointed me out to the SelectMethod option in asp.net 4.5 and newer. I created a test website that call my OData service using LINQ in the...
14 Mar 2022 by ahmedbelal
i need solution for repeat items in DataGridView i design form for Patients , i try to show Patient List in dataGridView But when i closed form and open DataGridView For Patient Again , Patient List is repeating for Example i have 10 row for...
14 Mar 2022 by Jay Stewart 2021
private void button1_Click(object sender, EventArgs e) { this.Close(); this.DGV.Rows.Clear(); DGV.DataSource = null; }
5 Feb 2022 by Graeme_Grant
You are looking at it backwards. The GridView, as the name implies, is a view into the data. So you filter/search the data and display the results in the GridView. UPDATE I did a quick Google Search and found this: Search records in GridView...
5 Feb 2022 by Tinsae Teku
Most search features of grid view in ASP.NET shows how to search data from a data list that is connected to a database. But my data in my gridview is list of name of books from a folder. It uploads files from folders and save them on visual...
23 Jan 2022 by Madhukar Krishna
Hi, I want to bind resources to gridview. I searched a lot but no success. I tried the following but it doesn't show gridview at all:- What I have tried: ...
23 Jan 2022 by poiuycat
you can get from your database like: male, female bind with datasource
9 Jan 2022 by Palash Sachan
How do i remove this blank space from gridview in asp.net? please see this IMAGE I want to remove this blank white space NOT hide this(as I know we can hide this border very easily) even after hiding the border the white unused space is there i want to remove that please see this IMAGE my...
9 Jan 2022 by Hasan Turer
Try this. Deleting or editing before binding to datatable is easier and more secure I think. public static void RemoveEmptyDataTable(DataTable dt) { for (int i = dt.Rows.Count - 1; i >= 0; i--) { ...
29 Dec 2021 by Member 15483157
CodeProject - For those who code[^]
29 Dec 2021 by Member 12433411
I have created a Web API and I need to use the "Get" service in an asp web form in a Grid View, how could I do this?What I have tried:I have created a Web API and I need to use the "Get" service in an asp web form in a Grid View, how could I do this?
20 Dec 2021 by melvintcs
DatabasedbItem:ID Description Price1 Apple 42 Banana 63 Papaya 7Query:SELECT * FROM dbItem WHERE price >= 10any possible that sql query can return an empty row for us if no record found? (like example below)Example:ID ...
20 Dec 2021 by Member 15474019
select t.* from (select 1 as adummy) a left join (SELECT * FROM dbItem WHERE price >= 10)) t on 1=1
2 Dec 2021 by Member 15421351
I am getting exponential notation for large numbers while exporting gridview binded with a dataset to export. I am using asp.net with c#. What I have tried: Code is as below: DataSet ds = objadmin.getAuditTrailReport(FromDate, ToDate,...
2 Dec 2021 by Richard Deeming
You are not exporting the grid to Excel. You are "exporting" it to HTML, whilst lying to the browser to make it think your content is an Excel file. Excel will do its best to import the HTML. But you will have extremely limited control over the...
1 Dec 2021 by #realJSOP
Looks to me like the gridview is taller than the window. Your problem is only indirectly related to the grid being filled.
1 Dec 2021 by Devendra Sarang
I have one gridview which is dock in parent controller https://i.imgur.com/ML7QWgx.png[^][^] so when my gridview is loading at run time, It is not showing horizontal scrollbar. Its is showing vertical scrollbar only. I have check that all the...
8 Oct 2021 by Ravi Sargam
I Have GridView Columns of Product(Label), Quantity(ASPTextbox), Rate(ASPTextbox) and Amount(Label), whenever i change rate or quantity i want to calculate amount(qty*rate) of product using javascript. function startCalc() { var rate =...
26 Sep 2021 by ahmed_sa
I work on data grid view I face issue I can't solve it so please if you can help me please I have data grid view read barcode it read barcode success and display items data issue when change quantity and press enter then I need it go to next...
16 Aug 2021 by OriginalGriff
While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for...
19 Jul 2021 by _Starbug_
I want to design a custom gridview with image inside it. I fetch images from database and also other data. How can i do that? Thanks. below link is what i want to achive it. link What I have tried: I used asp.net toolbox control but i do not know how to implement image inside columns of it.
11 Jul 2021 by xkarmax
I tried exporting my Gridview data to excel but nothing happens when I clicked the button. I have tried looking for the problem using breakpoint then it always stopped at gridData.RenderControl(htmlWrite); then it will go out of the function ...
11 Jul 2021 by xkarmax
I found the solution for this kind of problem you have to put triggers outside of the ContentTemplate . maybe because UpdatePanel is not compatible with FileUpload . You need to include this to your code ...
25 Jun 2021 by Relmon
Teacher logins and selects which lecture it would like to update student's grades. When it clicks button, Gridview retrieves student infomations and grades. When teacher clicks GridView's edit button, GridView automatically editing the first...
8 Jun 2021 by Jeff Franken
I have a gridview named GridViewMA. On each row of GridViewMA, I have a radiobuttonlist control named rbAdj_Entry. I currently have 5 requiredvalidator fields in the grid. if the user selects one value in the radiobuttonlist, I want to enable all...
31 May 2021 by Rinshad Hameed
I have a gridview in an aspx page. I have made it row selection by javascript. The selectedindexchanged event is not working when i am using master page. Otherwise it works fine. Is there any solution for this?Please see my code behind public partial class WebForm2 :...
31 May 2021 by ilkerimrak16
If you use commandbutton for your gridview, write your button's commandname anything like select etc...
24 Apr 2021 by Member 13890612
Hi everybody... I'm a beginner at asp.net webform, Can you please help me fix my problem? i have dx:ASPxGridView contain of 4 Column "productId","ProductName","Brand",and "Unit". I can get the value for 3 first column, but I need to get the item...
21 Mar 2021 by Member 10235977
I have a gridview which has a template field for time left for the project. It has another template field containing a text box. the user can fill up the text box and update the data on server by click of submit button but i want him to do it...
21 Mar 2021 by Arth01
after i read this, i think First you have to create one temp data table in database. when you enter data in text box and submit it its go in temp data table. when your time to update it in main table then load data from this temp table to...
15 Mar 2021 by TheBigBearNow
Hello everybody, I have a DataGrid that is being populated from a DataTable by a SQL database. My SQL creates a list of objects and I create the datatable and columns dynamically. I am trying to set the column width of each column so I can specify them to whatever width I want. My grid view is...
15 Mar 2021 by aherceo
public ProductsList() { InitializeComponent(); CreateProductList(); DataTable dt = DataTableProductList(productList); // it is assumed that productList is a public variable of type List ...
1 Mar 2021 by MichaelEriksen
I want to create a GridView dynamic with a buttoncolumn in each row and do a Click at that ImageButton. This ImageButton have a commandargument filled in - and I whish to resspond to that commandargument When I click at the button and do...
18 Feb 2021 by Member 13779417
Hi, I'm really struggling with this as I have yet to find a VB solution anywhere. In the gridview is a hyperlink to another page. Once you follow that hyperlink and then click back on the browser, I get browser error: Confirm Form Resubmission I...
20 Jan 2021 by DoingWork
Dear C# WPF Gurus I want to design my WPF Form Like this Image Imgur: WPF User Rights Image[^] Where All column names coming from an Enum names as Role. public enum Roles { Manager, Master, Engineer, Guest } What I have tried: Kindly...
20 Jan 2021 by Christian Graus
Once you add a datagrid, you can label the columns anyway you want and it's possible to foreach over an enum foreach (Suit suit in (Suit[]) Enum.GetValues(typeof(Suit))) { }
17 Jan 2021 by SHAJANCHERIAN
I need to validate a gridview (ie. is empty or not)(Gridview data will be filled by user through datatable.)In my code it is not able to find the Gridview1.and also advise my code / way is correct..//=======================================================
26 Oct 2020 by Member 14677180
I am working on a WPF application. I need a functionality that helps multiple people to work on the same screen(Grid Screen) without overriding each other's changes. What I have tried: Please help me on this. I am not getting how to achieve this
26 Oct 2020 by lmoelleb
You need to learn about network communication. While you can have computers communicate directly if they are on the same network, you will run into firewall issues quite easily. I recommend you make a HTTPS based API on a server - let the clients...
20 Oct 2020 by syuhaiba hamizi
I want to display all the duplicate data in this gridview. But, i dont have any idea on how it works. What i have tried seem not working at all. Mind to share any ideas? What I have tried: Protected Sub Button1_Click(sender As Object, e As...
20 Oct 2020 by programmer1010101
I am very new to C#. I am writing a program using visual studio c# where it will first ask the user to enter an employee name. Next, it will pass that name through an API and will retrieve and display the employee signature. I have completed this...
19 Oct 2020 by ycwong99
protected void LinkButton_Click(Object sender, EventArgs e) { String MyConnection2 = "Server=localhost;database=ovs;Uid=root;password=; Convert Zero Datetime=True"; DateTime time = DateTime.Now; ...
19 Oct 2020 by ycwong99
protected void LinkButton_Click(Object sender, EventArgs e) { String MyConnection2 = "Server=localhost;database=ovs;Uid=root;password=; Convert Zero Datetime=True"; DateTime time = DateTime.Now; ...
19 Oct 2020 by OriginalGriff
To add to what Richard has said, this is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried...
19 Oct 2020 by Richard MacCutchan
Label lblID = (Label)GridView2.FindControl("lblvID"); string voterID = lblID.Text; You are assuming that FindControl succeeded, but it may not. So first check that it returns a valid control reference, not null.
19 Oct 2020 by ycwong99
protected void LinkButton_Click(Object sender, EventArgs e) { String MyConnection2 = "Server=localhost;database=ovs;Uid=root;password=; Convert Zero Datetime=True"; DateTime time = DateTime.Now; //...
18 Oct 2020 by Patrice T
Quote: Show the error message and prevent duplicated vote 2 approaches: - Do a select for the student id, if the result is a record, the student already voted. This can get unlucky if student try to vote simultaneously on 2 computers. - Design...
17 Oct 2020 by ycwong99
protected void Upload(object sender, EventArgs e) { //Extract Image File Name. string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName); //Set the Image File Path. string filePath = "~/Uploads/" +...
17 Oct 2020 by OriginalGriff
Your INSERT syntax is wrong: cmd = new MySqlCommand("INSERT INTO candidate(candidateImage,path where studentID ='" + Session["UserName"] + "') VALUES (@Name,@Path)", con1); INSERT never has a WHERE clause - it can't because it doesn't return...
14 Oct 2020 by Sandeep Mewara
As shared there are tonnes of info on web, a similar query asked here at CP itself: how to display image from oracle blob data[^] Couple of References that would help you: Oracle BLOB data type and C# | Chanmingman's Blog[^] Insert /retrieve ...
30 Sep 2020 by Richard Deeming
Try using the naming container: protected void Select(object sender, EventArgs e) { Button button = (Button)sender; string ID = button.CommandArgument; GridView gvOrders = (GridView)button.NamingContainer.FindControl("gvOrders"); ...
30 Sep 2020 by Member 14947087
I have a nested gridview. On the top-level grid, I have a button that should call a stored procedure and and put that data into the nested gridview. Here is my ASPX page code
17 Sep 2020 by bjay tiamsic
Hi. I am having a weird issue here. I have an expandable gridview. When the plus sign is clicked, the row expands and shows a div with ASP.Net controls (some of these controls have postback) Everything works fine on Row Index 0 however, other...
15 Sep 2020 by bjay tiamsic
Hi. I am creating a web page with collapsible grid, so my gridview is nested and can be expanded/collapsed when the plus sign is clicked. Now, I need to highlight the row in line with the plus sign only (not including the expanded div) I used...
15 Sep 2020 by bjay tiamsic
Worked it out by using this var currentRowIndex = parseInt(rowIndex) + (parseInt(rowIndex) + 1); if (rowIndex == 0) { currentRowIndex = parseInt(rowIndex) + 1; }
9 Sep 2020 by Richard Deeming
Assuming the link button and list are in the same grid row, try: protected void Download_click(object sender, EventArgs e) { var button = (Control)sender; var list = (DropDownList)button.NamingContainer.FindControl("FileList"); ...
9 Sep 2020 by Member 14886708
Hello Developers I'm stuck on one problem in that I've a Parent GridView and Child Grid View And Child GridView has multiple rows and single column in the row I'm storing the Dropdown and next to dropdown I've a LinkButton for Download the file...
7 Sep 2020 by Herre Kuijpers
Extending the standard ASP.NET GridView control to add a vertical scrollbar in the grid
24 Aug 2020 by Member 12611727
Hi, I have a gridview populating from Json deserialization. Once click the button download, the json string will be displayed as gridview in the page. I can select any gridview row using chekbox and click send to store the data in my local db. ...
24 Aug 2020 by Garth J Lancaster
Quote: How to do this code checking? Maybe you need an additional column on the table in your ?remote database. When you 'download' and 're-store' the data in your local db (your terms) you update the column in the ? remote table/db to say...
4 Aug 2020 by Sandeep Mewara
For Insert, you need to try with ExecuteNonQuery on command and not ExecuteReader. ExecuteReader would not edit/update data in database. Please read here about ADO.NET and try: Accessing data with ADO.NET[^] Example: private void...
14 Jul 2020 by kozmikadam
Hello everyone ,My sql table has some duplicate item like this :id-- item_id -- user_name -- basket1 1 - John - Empty2 1 - John - order_13 2 - Mike - order_24 2 - Mike - order_35 2 - Mike - order_46 ...
14 Jul 2020 by Andre Oosthuizen
I agree with Zurdodev's answer, change your sql statement to load data/populate the grid with the correct returned data excluding the duplicates by using the SQL SELECT DISTINCT Statement - SELECT DISTINCT user_name FROM my_table ORDER BY id