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

Gridview 

15 Dec 2016 by Member 12882545
Hi.I have this query , using unpivot SQL statement. When I run the query on SQL server, it execute and gives out the result that I desired. But, when I want to use the same query on Gridview function on Visual Studio 2015, using VB , it said that " The Declare SQL construct or statement is...
30 Dec 2012 by nileshpujari
Iam getting this error while transferring data from gridview to excel, can any one suggest me the solution"RegisterForEventValidation can only be called during Render();"I got a solution that i should do EnableEventValidation=false and generate the event VerifyRenderingInServerForm(Control...
30 Dec 2012 by WajihaAhmed
I had once done this with some help from here:http://stackoverflow.com/questions/8908363/exporting-gridview-to-xls-paging-issue[^]See if that helps you too :) Looking forward for your comments.
30 Dec 2012 by nileshpujari
The button that is supposd to generate the excel file..;place that button in the tab of the tab...and if ur grid is doing paging then while exporting the data into excel use the Datatable instead of using the gridview coz if u use gridview then it will not generate proper excel file...or u...
9 Aug 2012 by snamyna
I am quite confuse why my code does not accept any gridview properties likeOnRowDataBound = "gdPartReg_RowDataBound"OnRowDeleting = "gdPartReg_RowDeleting"OnRowCreated = "gdPartReg_RowCreated"and etc..How to solve this?This is my page directive :
14 Aug 2012 by AshishChaudha
Have you checked is there any more cs page which inherits the same class.ThanksAshish
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 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 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...
26 Nov 2012 by sumans4324
Hello All,Greetings for the day..!I have a gridview(winform) bound to "obect data source(nhibernate object)" with "Aut-generate cols" true, which I use only to display & filter the data. Now the inner object(or master object's is not displayed). I know pretty well that all the objects...
26 Aug 2013 by VIP Venkatesan
In my gridview i've 2 fields i want gridview like----------------------- STATUS || ACTION----------------------- Active || Block Blocked || UnBlockthat is if my status field is "Active" then my action link button should be "Block" and its commandname...
26 Aug 2013 by VIP Venkatesan
Here i've given my rowcommand and row databound code.. can u help me by using this?protected void grdbroker_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Block") { int i = Convert.ToInt32(e.CommandArgument); ...
26 Aug 2013 by VIP Venkatesan
protected void grdbroker_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Block") { int i = Convert.ToInt32(e.CommandArgument); int recid = Convert.ToInt32(grdbroker.DataKeys[i].Value); ...
29 Aug 2013 by VIP Venkatesan
function total() { var bags = document.getElementById('').value; var net = document.getElementById('').value; var...
16 Sep 2013 by VIP Venkatesan
function totalupdate() { var bags = parseInt($("[id*=gvtxtbags]").val()); var net = parseInt($("[id*=gvtxtnet]").val()); var fromslno = parseInt($("[id*=gvtxtfslno]").val()); if (bags != "" && net != "") { k =...
24 Jul 2014 by Shubham @R$
My Question is that ,"I have Gridview Which I had Bind With Database query(SELECT * From ) ,Now I want to add New Row and DAta In it, in Grid View ,Through the Txtbox etc Controls but I dont want to Insert That Data In My Database. In Short ,I want to Hold my New Data In New Row in Gridview....
28 Aug 2013 by Member 10238240
I have a windows aspx app I created. The app has several input forms, & several gridview reports which all have an edit hyperlink to form edit page(s). Some fields in the gridview are populated with data from SQL tables, other fields are blank. The edit form is so the user can make changes to...
28 Aug 2013 by Murali0195
Hi...See this link for gridview.edit,delete and update in gridview[^]Thank u.
23 Mar 2011 by Laksh112
Hi, I have a grid view and it shows the data from a table on page load.now there is a search button which when clicked shows textboxes and one can enter text by which they want to search the data . when you click go ,the same grid view must show the search results.So i wrote ado.net code on...
23 Mar 2011 by Wendelius
You cannot have 2 data sources at the same time. Why not use a LINQ query on your datatables and from that query extract a new collection or data table which you then use as a data source to the gridview.
23 Mar 2011 by Vijay Ankit
Is it because you use first datasourceid to bind your gridview and then on button click you bind the gridview with DataSource? 1. One easy option is to set datasourceid to null on button click. Something like below:GridView1.DataSourceID = null;2. Other option can be to bind your...
25 Jul 2011 by Shameel
The Car class implements the INotifyPropertyChanged interface but the actual data source is the Cars object.If I were you, I would create a custom Cars class (not just a collection) and implement INotifyPropertyChanged interface in the Cars class. And whenever a Car was...
25 Jul 2011 by BobJanova
To fully support data binding the collection should implement IBindingList (i.e. BindingList) or INotifyCollectionChanged (e.g. ObservableCollection). You can use a BindingSource but you still have to make sure that it is notified of changes if the underlying collection doesn't do that...
23 Oct 2013 by Ravindhar Gaddam
How to decrease an amount from total of column amount in griview when remove a row from a gridview???Please help me in this..i invested many hours on this..i would be thankful for your reply
2 Dec 2010 by tulasiram3975
hi all I created manually edit delete update for grid while page loading getting an error on line:GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];The error is:'System.Web.UI.WebControls.GridViewUpdatedEventArgs' does not contain a definition for 'RowIndex' and no extension...
2 Dec 2010 by tulasiram3975
ok sorry guys i had made small mistake i am writing code in rowupdated event not in row updating thats it now my code is working fine
12 May 2014 by AR547
Hi Developers,I am facing the following issue regarding comparing my gridview certain column data with checkboxlist item text.I have a checkboxlist which has only 6 items.ABCDEFWhen the gridview is populated from database and the 3rd column i-e: Cell[2].Text has the...
28 Oct 2013 by AR547
protected void GridView3_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowState != DataControlRowState.Edit) // check for RowState { if (e.Row.RowType == DataControlRowType.DataRow) //check for RowType { ...
12 May 2014 by AR547
Requirement:I need to create a Stacked Bar Chart in my web application based on 2.0 plateform. I dont want to use any third party tool or chart in VS because I cannot access the chart control when working on 2.0 plateform. It only supports 3.5.Is there any professional developer present...
7 Oct 2013 by VICK
Do have a look on Google API.....Pretty Easy to deploy in an ASP.NET application.. and much helpful in chart creation...https://developers.google.com/chart/interactive/docs/examples[^]Hope it will help... :)
7 Oct 2013 by amnk.info
This is very nice and creative chart control.. try ithttp://docs.fusioncharts.com/charts/contents/guide-for-web-developers/csnet/CS_BasicExample.html[^]
18 Dec 2013 by AR547
"select replace(TASK_ATTACHMENT_PATH,'D:\\Live CMS\\requestAttachments\\23101\\') from TABLE";The Function of REPLACE worked perfect in this scenario in SQL Qyery.It gave me only text after \23101\ which I needed to display.:)Thanks to all for great work too.
12 May 2014 by AR547
Hi guys,I have the following sql query:"select task_attachment_path \"File Name\" from AttachmentTable";I got the output in my gridview's cell as:| File Name || ====================================== || D:\Live...
18 Dec 2013 by CPallini
Use the Path.GetFileName[^] method (see the sample code in the documentation page).
18 Dec 2013 by Snehasish_Nandy
You can use SUBSTRING[^] in sql.e.gselect substring('select task_attachment_path \"File Name\" from AttachmentTable',31,9)
18 Dec 2013 by Maciej Los
Test it:DECLARE @ffilename VARCHAR(255)SET @ffilename = 'D:\Live CMS\requestAttachments\23101\Development File.txt'SELECT REVERSE(LEFT(REVERSE(@ffilename),CHARINDEX('\',REVERSE(@ffilename))-1)) AS ShortFileName, @ffilename AS FullFileNameResult:ShortFileName ...
18 Dec 2013 by Rakesh Meel
visit here...http://msdn.microsoft.com/en-us/library/t97s7bs3%28v=vs.110%29.aspx[^]or http://www.w3resource.com/sql/character-functions/trim.php[^]
12 May 2014 by AR547
Solve this issue regarding dropdownlist and gridview. The scenario is as following: I have one dropdownlist and one gridview. Data from database is binding to dropdownlist. now dropdownlist has 1000+ employee names in DataTextField and employee emails in DataValueField. there is an ADD button...
17 Sep 2013 by Harshil_Raval
Hi,Try this.protected void addemp_Click(object sender, EventArgs e){ DataTable empemails = new DataTable(); int srno = 1; empemails.Columns.Add("Sr.No"); empemails.Columns.Add("EmpName"); empemails.Columns.Add("Email"); foreach...
12 May 2014 by AR547
I have a Gridview, in which i am using Fileupload Control as an item template.there are max 6 rows can be generated in this gridview.As I am sending this gridview to email after converting to HTML I WANT TO SEND THOSE FILEUPLOAD FILES AS AN ATTACHMENT WITH THIS EMAIL. THE GRIDVIEW WILL BE IN...
23 Sep 2013 by muhammadwaseem
why don't you use attached file property for detail follow the link http://stackoverflow.com/questions/13553242/how-to-attach-multiple-files-to-the-email[^]for file uploader why you use gridview actually am not understand your problem will you plz explain in detail what you want...
12 May 2014 by AR547
I have a GridView in my web application. Having 9 Columns. I just need to send the detail of 6 columns from it through email. What will be the accurate procedure of this issue. Also how I will convert those column into HTML format.... Please Help.
17 Sep 2013 by Ashishmau
You can take you gridview into datatable and then you can remove n number of columns using dt.column.remove(columnname) something like that and then you can convert your datatable to htmltable by using function given in below link and then send this html table in you...
19 Sep 2013 by Diana Tsax
First step: convert gridview to html table and remove the columns you don't want private string getHTML(GridView gv) { this.OrderGridView.AllowPaging = false; this.OrderGridView.AllowSorting = false; this.OrderGridView.EditIndex =...
19 Sep 2013 by Murali0195
Hi...See this. May its useful to u.//Reads values from ur gridview1.GridViewRow gvRow = (GridViewRow)(sender as Control).Parent.Parent;//assigning gridview1 controls to strings like blow.string username =...
19 Sep 2013 by AR547
THERE ARE TWO TABLES WHICH I AM SENDING TO EMAIL.• HTML TABLE - GETTING VALUES OF MY SERVER CONTROLS IN THE HTML TABLE• GRIDVIEW - AFTER CONVERTING IT TO HTML.SENDING THE HTML TABLE AND GRIDVIEW(HTML FORMAT) TO EMAILprivate void emaildatatable() { string reqini =...
29 May 2014 by Tarun Jaiswal
m using GridView control in Asp.nethere in my database table m having some row empty or NULL,GridView control is linked with SqlDataSource, When GridView is displayed on webpageNULL column displays nothing it is empty.how i can fill that column with some default text or string only...
29 May 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
You can get the each Column Data in RowDataBound Event.So, inside the Event, check if that is blank or not.If blank, then replace it with any default text.
29 May 2014 by Tarun Jaiswal
yes Tadit Dash i have solvedit yesterday only.by just using NullDisplayText property in GridViewn thanx for your reply
18 Oct 2010 by Gagey1971
A simple .NET control to display the 'standard' 13x13 grid for two card poker hands.
28 Oct 2014 by Member 11042100
ShadingAnalysisDataSetTableAdapters.tbl_CadEngineersTeamTableAdapter cd; cd = new ShadingAnalysisDataSetTableAdapters.tbl_CadEngineersTeamTableAdapter(); DataTable dt = new DataTable(); dt = cd.GetAvailableData(ddlCircle.SelectedValue); // Getting details of unassigned site int...
28 Oct 2014 by Praneet Nadkar
Hi,The exception's first sentence tells it all "A data item was not found in the container"Turns out that you have a null item in the list due to some filtering of data that you have included (transformation from array types to list type is involved). Check for the null values in...
28 Oct 2014 by Member 11042100
Now it is working and grid view control showing strArr values. Thank You.protected void ddlCircle_SelectedIndexChanged(object sender, EventArgs e){ ShadingAnalysisDataSetTableAdapters.tbl_CadEngineersTeamTableAdapter cd; cd = new...
18 Jan 2013 by Andrey Sitaev
Here I placed source files, binaries and brief instructions for FastGrid control.
12 Jul 2011 by gani7787
Hi,I am not able to read selected dropdown values in the gridview_rowupdating event.it will read always which was bind the last read values.what is the problem over here..? ...
12 Jul 2011 by Christian Graus
Way too much code here, but if you populate your list every time, and do it before prerender, then the reseting of the data also causes the selection to be lost. Use IsPostback to check.
8 Oct 2011 by karthikeya.A
Hi To All, I wants to edit a grid view Row.My issue is when I click a particular row that row have to be edit as well as when i double click the row the content will open in new window (or) model popup and provide edit option there.Can any one help me? Thanks in advance.
8 Oct 2011 by NewPast
you may find helpful ideas in Flexible ComboBox and EditingControl
11 Jul 2012 by sadegh_rusta
i have a grid viewin my grid view is 3 columns1 :product id2:textbox 3:buttoni want add to product count field with click on the buttonadded value is textbox.texthow i can access textbox.text with click on the button of that row?
11 Jul 2012 by Shemeer NS
Add an event to the button Button1_Click then in that click event (bubble event) you can find the controlprotected void Button1_Click(object sender, EventArgs e){GridViewRow row=((Button)sender).Parent.Parent as GridViewRow;TextBox t=(TextBox)row.FindControl("textbox ");//t.Text -...
27 Jan 2012 by jokertin92
Hi all, I've created a gridview in which I have added a 'div' section and under that I've created a Listbox. Now I want to assign the datasource for the Listview in RowDataBound event. But I'm unable to access the Listbox. Suggest me how can I achieve this. Here is my code.
24 Apr 2012 by jokertin92
It's solved by using page.findcontrol method.
1 Apr 2011 by snamyna
Hi,I have a gridview with a radiobuttonlist in one of the columns. The radiobutton list consist of Yes/No options where the users need to choose. I want to access the gridview row by row to get the selectedvalue of the radiobutton list but I do not have any idea how to access it one by...
1 Apr 2011 by sekharkaza
Following is the wayGridviewRow gvr=GridView1.Rows[GridView1.SelectedIndex];RadioButtonList rbl=gvr.findcontrol("rb1") as RadioButtonList ;string result = rbl.SelectedValue;
8 Apr 2011 by avigodse
I agree with answer above, just a little enhancement.Follow this way;foreach (GridViewRow row in GridView1.Rows){ RadioButtonList rbSelect = (RadioButtonList)row.FindControl("rbl"); ////TO DO: Write the required code.}I could have provided this code in VB.Net, but we'll...
26 Apr 2011 by johnravi88
foreach (GridViewRow gvr in GridView1.Rows) { RadioButtonList rb = gvr.FindControl("rb1") as RadioButtonListstring ans=rb.selectedvalue;}
11 Dec 2019 by pcprogrammer9
i want to access all checked row in RadGridView(Telerik component) via GridViewCheckBoxColumn. Note : User select checkbox at run time ... Screenshot What I have tried: string s1 = ""; for(int i =0; i
11 Dec 2019 by Simon_Whale
A quick google gave me this How to get all row with checkboxcolumn checked in UI for WinForms GridView - Telerik Forums[^]
6 May 2012 by kunaltilak
Dear friends,I want to enter and insert all rows in one go from Gridview textboxes into database , initially all textboxes are empty. I have 33 rows and 7 columns of text box in Gridview and 1 column for display purpose in unicode (extreme left) .For simplicity of code...
6 May 2012 by kunaltilak
Answer is:Just has to EnableViewState="false" for both Gridview and textbox.
5 Jul 2010 by anada8886
I have created a gridview with 2 template fields created at design time. I want to generate more template fields(gridview columns) dynamically at runtime,because no. of columns in the gridview is varying every time.I also need to have a textbox inside every template field.I have done up till...
5 Jul 2010 by Mehul M Thakkar
What you have to do is, you need to recreate the template columns with textboxes again on postback (on click of submit button), then and then only you will get your template column as well as the value of textboxes
5 Jul 2010 by Mehul M Thakkar
It will retain its value due to view-state. Just you need to make sure that the id which you have created for template columns and textboxes at initial page load, should be same after postback.
6 Jul 2010 by Mehul M Thakkar
I think in IsPostback(), you had written the code of adding template columns and textboxes in those columns.
16 Dec 2011 by panashwani
i think use HTML table at run time.
19 Mar 2013 by avinash_thakur86
hi, i have a gridview in which i am using checkbox in each row. i am trying to access checkbox of each row and trying to find out which checkboxes have been checked.buut when i try to run the below code.the condition always stands to be false and the inner if condition is never reached by the...
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 ==...
14 Oct 2012 by Member 7810658
HiI'm trying to created a simple solution to a problem that requires GridViews to be added dynamically.I put known code for the grid into a StringBuilder object and passed its value to the InnerHtml of a div. I'm not using a Panel because the I don't want to spend more time testing a...
14 Oct 2012 by n.podbielski
I does not work that way. .aspx page is not a file with string contents. It is later compiled to complex class witch later spit it's contents with Response.write. If you have to add dynamic controls you have to add it as objects to some other control via ControlColection property. If you...
4 Jul 2013 by snamyna
I tried using Dim headerRowText As String = gdData.HeaderRow.Cells(6).Text to access gridview header. However, my gridview header is merged and using this method only can access the second header row. How can I modify the code to access first header row (05/07/2013)? ...
28 Jan 2014 by Member 10556011
Hi,I downloaded "Grid.MVC" and liked it very much. I use it to display strongly typed class into grid. my question is: How to add a column into the grid for display purpose?Thanks very much.Hugh
3 Dec 2014 by januskarthik
I am taking a grid-view with two text-box control and one checkboxlist control. While I am adding a new row in grid-view dynamically, then the two text-box contain the value in the previous row but the items in checkboxlist control not displayed in previous row.I want to maintain the state of...
3 Dec 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Inside Button Click Event, you are getting the CheckBoxList as...CheckBoxList assignee = (CheckBoxList)grvStudentDetails.Rows[rowIndex].Cells[5].FindControl("chkAssignees");Now get all the checked ones and store their item index separated by comma or something in one column...
22 Jun 2015 by Mahatma Aladdin
I have created a webform which imports the excel file into gridview. Now I want to add checkbox control to each header (along with the header text).Below is the code where I am 1. Importing the excel data. 2. Store it into a datatable 3. Creating gridview dynamically 4. Binding the data into...
25 Jun 2015 by Lucifier Rocks
Rectangle rect = dataGridView1.GetCellDisplayRectangle(0, -1, true); rect.Y = 3; rect.X = rect.Location.X + (rect.Width/4); CheckBox checkboxHeader = new CheckBox(); checkboxHeader.Name = "checkboxHeader"; //datagridview[0, 0].ToolTipText =...
25 Dec 2013 by Member 10467514
Here I created a grideview containging joblist.below that i added one datadetailview .when anybody select the row in gridview it will shown in detail view...I added one column checkbox in the detailview.when anbody select the checkbox and click apply button below ,the data in the detailview must...
25 Dec 2013 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
On Apply Button Click Event, do the following things.Initialize a new DataTableLoop through the DetailsView Items/Rows. Inside the loop...Get the CheckBox Control by FindControl or somethingDetermine if it is Checked or not by CheckBox.Checked Property[^]If that is checked add that...
18 Mar 2012 by Member 8740834
Hi friends, first of all my english is not good..pls dont mind.i need help from asp .net experts.because i am not expert in asp .net.i am doing a acadamic project.for that need a help in a form..in billing form..i tried many times and searched in whole net..i have no good knowlege in...
21 Mar 2012 by Mohamed Mitwalli
hi , Hope it help you DataTable dt; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=test;Integrated Security=True"); con.Open(); ...
13 Feb 2014 by dash2020
Hi allI have a datagrid where I am showing contact list of our people with their individual email address/s. I have added a checkbox.I want to check if outlook new message is open if it is open then add all selected email address (datagrid cell value) to the BCC field.Here is my...
8 Nov 2014 by Member 11218159
I am adding two columns to GridView as below DataGridViewLinkColumn Editlink = new DataGridViewLinkColumn(); Editlink.UseColumnTextForLinkValue = true; Editlink.HeaderText = "Edit"; Editlink.DataPropertyName = "lnkColumn"; ...
10 Nov 2014 by rahulkichur
Create a UserControl having Edit and delete link as per your requirement. And then you can use the same code as in the following linkhttp://social.msdn.microsoft.com/forums/en-US/winformsdesigner/thread/c28399bb-9d50-4a1e-b671-3dbaebb5cc69/Or you can host that UserControl in your...
26 Jul 2014 by Pratham4950
Here, I want to add multiple items on click on add button, which mention below image.when users add on button, to in txtqty,Text value is display on gridview, again same thing,means, multiple time users can click on add button one by one, and then after click on submit button,so all...
26 Jul 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
You need to add item to the DataSource of the GridView and bind the GridView again. If you need to insert that to Database, then do so first. Retrieve the rows again and bind to GridView.
14 Nov 2011 by GC Theja
hi all, I'm very new to dotnet programming. I'm using c#. as per requirement I'm desiging order taking form from customer in a project. In that form, when u run the form(click on order button) empty grid should load and it should contain 5 columns (S.No auto generation, item (dropdown list), mrp...
15 Nov 2011 by GC Theja
after clicking the insert button the data in grid should save in db thats all. If any one want to see that record they can view. In some situations , if editing needed then it should be editable. while priniting receipt(its another), by mentioning the orderid the total oreder(from order tbl)...
21 Nov 2011 by GC Theja
I've achieved the requirement by creating the row dynamically and adding the controls. in find cntrol field I've attached the existing control. It's working now.I found the example at following...