.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to change the first column of auto-generated columns of a gridview.

Posted By:      Posted Date: October 17, 2010    Points: 0   Category :ASP.Net

Hi, I have a gridview which makes use of a datasource. The columns are auto-generated.

Right now, my task is to make the first column into a url column. Does anybody know how to do it?


View Complete Post

More Related Resource Links

Add "a ref" to a column in a gridview where the columns are auto-generated


 I need to make a link for all the rows in one column of a gridview(VB .Net) where the grid has been auto-created from the data source. The link would simply point to another ASP details web page. The examples I have found have all been in C# and I don't quite follow them.



DataGridView>Edit Columns> Column Read Only property is unwilling to change

Hello, I am facing the following mystery: When changing the read only property of a column to false and reopening the "edit columns" window, it mysteriously turns back to true. Even when closing the designer and changing it in the designer code, the resulting execution does not allow edit, as well as when re-opening the designer you see true again.             this.numberDataGridViewTextBoxColumn1.DataPropertyName = "Number";             this.numberDataGridViewTextBoxColumn1.HeaderText = "Number";             this.numberDataGridViewTextBoxColumn1.Name = "numberDataGridViewTextBoxColumn1";             this.numberDataGridViewTextBoxColumn1.ReadOnly = true;//False is required We thought it might be related to data binding. rebinding the grid did not help as well. The is no other place in the code where it changes. Please advice, Thanks

Clone GridView-Columns Widths (assign the Column-Width from 1 Gridview to another)


Hi everyone,

I've googled quite a lot, but couldn't find a solution - in the end this forum always helped me out the best! :)

This is my problem: I've got my Gridview gv_1, it gets its data from the code behind through a DataSet, gets generated like it should be, and assigns it's column-width to the longest entry in the datarow. Now I've got my Gridview gv_2, which has other entries and column widhts (gets filled the same way) - what I want to do is to change the width of the columns that the gridviews have the same overall width.

I've uploaded a screenshot: http://stepdown.elementfx.com/image16.jpg

What I've already tried is playing around with the GridView.HeaderRow.Cells[0].Width-Property, but when I debug it (after it's DataBound) I've got no values, meaning the values are "0.0" etc. The try to assign a value also didnt work (not directly for Width and not for Width.Value).

The next problem I could encounter is that my second GridView has no visible HeaderRow - and as far as I've googled people always somehow set the width of the column - but I'm not even that far yet. ;)

So the perfect solution (working in my head at least) would be to get the width of each column from the 2 gridviews, pick the larger one, and ass

Change the Status in Gridview column




I have a gridview and a button-Start in aspx page.

In gridview 3 columns checkbox , Name and Status.

Select multiple columns and click on Start then Status column for selected rows should be changed to "Starting...", later it should be changed to "Started".


But it is showing directly "Started". In the mean time i should see "Starting..." also.


Here is my code


<b>Aspx page</b>


 <asp:GridView runat="server" AutoGenerateColumns="False">


<asp:TemplateField>   <ItemTemplate>                                                    <asp:CheckBox runat="server"/>



<ItemTemplate> <asp:BoundField HeaderText="Name" DataField="Name" />  

<asp:TemplateField HeaderText="Status">          &nb

Problem with gridview dynamically generated columns and textboxes


Hi All,

 I am using asp.net/c# application. In my application, I have a gridview.

<asp:GridView id ="gv_QuestionList" runat="server"> </asp:GridView>

In Code Behind, I created dynamic textboxes and DropDownLists on RowDataBound.

protected void gv_QuestionList_RowDataBound(object sender, GridViewRowEventArgs e)
            if (e.Row.RowType == DataControlRowType.DataRow)

                if (ObjQMDO.QuestionType == "TextBox")
                    TextBox txt = new TextBox();
                else if (ObjQMDO.QuestionType == "Dropdownlist")
                    DropDownList drp = new DropDownList();
                    drp.DataSource = ObjQMDA.GetQuesTypeValues(QUES_ID);
                    drp.DataTextField = "QTYV_QuesTypeValue";
                    drp.DataValueField = "QTYV_ID";
                    drp.Items.Insert(0, new ListItem("Select One", "0"));

                else if (ObjQMDO.QuestionType == "Radio")

Auto Populating SharePoint List Columns based on value in one column

   I have a SharePoint List where I want to auto populate the value of some of the columns from another List based on a field "Title" which is primary & unique....
   I want to auto populate them when clicking "New Item"  and entering data... you put the "Title" value and it should match the Title value from another List and auto-populate some the columns...

   Please any idea would be highly appreciated....

Thanks in advance

How to remove auto generated right blank column from the wpf datagrid?


i have already use this.


Accessing Auto-Generated Textbox in Gridview


Dear All,

 I have a gridview which has autogenerate Columns Property "TRUE", and i'm dynamically binding this gridview with columns with sql database dataset. there is no data in sql but i am successful in showing blank gridview on form, now i want textboxes in gridview attached with each column, so i wrote code in RowDataBound which generates textbox automatically and assigns ID to each textbox, nw i want to insert that data from textbox to database but i'm not getting text which is entered in those textboxes, as i am accessing that textboxes using findcontrol and passing the id like gridview1_ctl03_text0. but i''m not getting any value from textbox please help?? 

In short i want to access auto generated textbox (with out any id predefined ) values from footer of gridview ?can any one please help?

Gridview column based on other columns


I realize this is a simple question.

I have a gridview with 3 columns, price, tax, and total (for example).

  I want the total column to contain price + tax. 

I've set all three columns to be templated, although maybe they don't need to be.  This grid is read-only. 

I'd like to do it in code and not in a Bind, because there are some other calculations I need to do for other columns and it's easier for me to do it in VB. 

Do I do this in pre-render for the label in column 3? If so, how do I access the contents of the other columns in that row? 



How to change alternative color in asp.net gridview rows and columns?

In this article, I will show you how to set alternative color for gridview rows and columns in asp.net.

Adding Multiple Columns and Rows in GridView without using a Database

This article describes on how to add multiple columns and rows in GridView without using a database. Basically the GridView will be populated with data based on the values entered in each TextBoxes on Button Click and retain the GridView data on post back.

Tooltip for GridView Column Headers (ASP.Net)

I just wanted to add auto tooltips for my GridView headers. There are couple of ways but I don't want to use javascript and wanted to use simple 'title' attribute. It took couple of hours to get the working code supporting sortable columns. I thought it will be very useful for others. Here's the code and logic behind it.

add columns with textboxes in gridview using C#

'm working on a shopping cart in a website and I have my items(which have been added to the cart) in an arraylist. And using these values I've read the rest of the values from the db and and have populated on the gridview successfully.

Sorting GridView Columns Manually

We all know that GridView columns can be sorted automatically when SQLDataSource is being used. But what if you are not using SqlDataSource to populate the GridView. Sorting the GridView manually is pretty straight forward task take a look at the code below

How to let user edit selected gridview columns, not entire row



I've got a gridview I would like to let the user edit a couple of columns.  Seems like everything I'm coming across so far makes the entire row editable.  

Hopefully the solution isn't too complicated.  Can someone point me in the right direction?


Use a column as parameter for a sds in another column; gridview


Hola, I have a gridview which is bound to a sds which returns 7 columns and I added two columns from the GUI.  What I want is to fill up the 9th column with DDLs and these  DDLS will get their data from a different sds which is using a stored procedure with a single parameter.  I created the 9th row, used template field, made the sds for 9th row, the stored_procedure, threw a DDL in Item template and all  I need now is to pass a parameter in the first column to the sds in the 9th column.  I can code this but i'm getting tired of aspx.cs :) and would like to do it from the GUI.

Bug: Does not change column type from nvarchar to ntext


Scenario: If you create a table with a column of type nvarchar, populate it with some content and try to modify it using the WebMatrix editor, from nvarchar to ntext, it does not display any error message or warning that this is not possible. It silently saves and reverts the change, back to nvarchar. Wasted some hours on this issue as I thought my column was ntext, but in fact was still nvarchar.

Expected behavior: It should change to ntext, or if SQL CE doesn't support that, it should notify the user that no change was applied.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend