.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

Hi All, Gridview header dynamicaly addingTextBox

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :JavaScript/VBScript

I am trying to display the gridview header in the textbox at dynamically.i need to change the textbox values while population the gridview then i need to get the header textbox values in button click event.

Can anyone help me out from this?

View Complete Post

More Related Resource Links

Create ToolTip for GridView Header

The following allows you to add a tooltip to the header links of your GridView, a feature that is lacking.

How to Fixed GridViews Header and Footer when scrolling in asp.net?

This article is to show you how to Fix GridView''s Header and Footer in a simple code with CSS and JavaScript

Custom Grid View Header - Grid view Row Created event vs Gridview row databound events ?


Hi Gurus ,

It happened to add an extra Gridveiw Header in row_databound event , It did worked fine on !Postback but disappered on Page.Postback . Quick google search guided me to move the event to Row_Created event and every thing is okay .

Can any expert post some pointers , differnces between grid row_created vs row_databount with some sample table data created dynamically  behaviour of both the events in !Postback and page.Postback .

Thanks a tonne in Advance and  any inputs will be valued and appreciated .

how to Gridview Header should be Stable in asp.net?

HI all, i have gridview with 100 columns,if scorll down records should be comes down but Header of Gridview should be Static, how can i do that.Please help me.Best Regards,Thiru

Footer and Header in Empty GridView

How to make GridView to show Header and Footer when it hasn't got any rows?

getting the AutoComplete inside a gridView Header?

 Hi all Could anyone please point me in the right direction to getting the following 'autoComplete Extender' into the Header of the gridView below please  <asp:GridView ID="gvAllData" runat="server" AutoGenerateColumns="False" DataKeyNames="IDNo" DataSourceID="dsAllData" allowPaging="True" allowSorting="True" GridLines="None" CellPadding="4" ForeColor="#333333"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:TextBox runat="server" ID="myTextBox" Width="100" autocomplete="off" /> <cc1:AutoCompleteExtender runat="server" ID="autoComplete1" TargetControlID="myTextBox" ServicePath="AutoComplete.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="2"

How to get Checkbox value created at runtime above gridview header


I have creted a checkbox for each column of grid at the top of the header in row created event. I need to check wheather checkbox is checked after button click event.

//Build custom header.

                GridView oGridView = (GridView)sender;
                GridViewRow oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
                TableCell oTableCell = new TableCell();

                //Add Staff_ID
                CheckBox chkStaffID = new CheckBox();
                chkStaffID.ID = "chkStaff_ID";
                chkStaffID.Text = "Hide";
                chkStaffID.CheckedChanged += new System.EventHandler(chkStaffID_CheckedChanged);

Gridview Fixed Header Issue


   position:relative ;
   z-index: 10;
2.Assign Datagrid Header's cssClass to Freezing
<HeaderStyle ... CssClass= "Freezing" ...></HeaderStyle>


This is working fine in Internet Explorer but not working in firefox. can anybody please help me to say why its not working in firefox

gridview header formatting



Using C# to develop a web application. Have a gridview to display data from the a sql table.

The headers of the gridview is achieve using a table. Need to format the header cells to align with the columns of the gridview.

Currently I'm using a trial an error method to set the width of the header to align with the gridview columns. Can I align the Table header to concide with the gird view column width progarmatically?

Here is my ASPX code

<div id="ProjectTableHeader" runat="server"
        style="background-color: #993300; height: 40px; width: 300; margin: 0; padding: 0">
        <table cellspacing="0" cellpadding="0" rules="all" border="1" id="tblHeader" style="font-family: Arial;font-size: 10pt; width: 300; color: white; border-collapse: collapse; height: 100%;">
                <td style="width: 64px; text-align: center">
                    Project Owner

Merging gridview header after binding in winforms



Note : I am talking about Winform grid only

I want to bind a grid, structure should look like below after binding with the datatable,


    26_sept            l         27_sept          l            28_sept       l           29_sept

col1 col2 col3 col4 l   col1 col2 col3 col4  l   col1 col2 col3 col4 l  col1 col2 col3 col4

                           l                               l                              l


Here, I have datatable dt 16 columns as below but no parent header

col1 col2 col3 col4 l   col1 col2 col3 col4  l   col1 col2 col3 col4 l  col1 col2

How to Use Same Header Name for Multiple Column in GridView ?



Hi All ,

         This is my  Needed view ,


                           Report1                 |                          Report2                         | - Main Header


SEL1    |  SEL2    | SEL3   |     SEL4   |       SEL1    |  SEL2    | SEL3   |     SEL4   |   - Sub Header



But afte

Gridview Header Columns


I want to change the text in headers in gridviews based on information in a database.  I want to databind to a gridview heading 

Need to remove the border from gridview header


I have created a custom gridview that show "Select All | Clear All" hyper links in header to select the checkboxes in the gridview. That means that I have added these two hyperlink controls to the gridview header and am not showing the actual column headers.

        private void CreateMyHeader()
            GridViewRow row = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);
            TableCell th = new TableHeaderCell();

            th.HorizontalAlign = HorizontalAlign.Left;
            th.ColumnSpan = this.Columns.Count+1;
            th.Font.Bold = false;
            th.BorderStyle = BorderStyle.None; //Not working

            HyperLink hlCtl1 = new HyperLink();
            hlCtl1.ID = "{0}_HeaderLink1";
            hlCtl1.NavigateUrl = "javascript: SelectAll(true)";
            hlCtl1.Text = this.HeaderSelectAllLinkText;

            Label lblSeparator = new Label();
            lblSeparator.Text = this.HeaderLinkSeparator;

            HyperLink hlCtl2 = new HyperLink();
            hlCtl2.ID = "{0}_HeaderLink2";
            hlCtl2.NavigateUrl = "javascript: SelectAll(false)";
            hlCtl2.Text = this.HeaderClearAllLinkText;

Problem adding multiple header rows to a gridview


Hello all!

I'm having difficulty adding a repeating header row, every x rows, to a gridview.  I'm able to add the header only once with the below code.  For some reason it will only add it during the last iteration through the for/next statement.  I tried manually adding three separate .addat statements to different rows and it only executed the last .addat statement.  I couldn't find any information on why it's only working the one time and I hope someone has a fix or better solution.

Thanks in advance!

Code snippet (Note the IsWhole() function verifies that the rownumber divided into a whole number):

Protected Sub Gridview1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles Gridview.DataBound

        Dim grid As GridView = TryCast(sender, GridView)

        If grid IsNot Nothing Then

            Dim row As New GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal)
            Dim header As GridViewRow = POSTURE_RESULT.HeaderRow
            For i As Integer = 0 To POSTURE_RESULT.Columns.C

How to access multiple header rows of the gridview in Render method


I have extended a gridview to add an additional header with following two hyperlink controls "Select All" and "Clear All". These will operate on checkboxes in the data rows of the grid. I hide the column headers as I only want to show one column with checkboxes and "Select/Clear All" links. Everything is working as expected. 

Now, I wanted to add a scrollbar to my grid control, I did add the scroll bar using div but what it does is, it includes the "Select All and Clear All" links aswell. I only need to add the scrollbar to datarows and not to the header.

I am trying to extend my control to include hte scrollbar by adding div during Render function. But how will I determine or loop through header rows? How will i get the header row with hyperlinks that I created above?? In Render if I do this.HeaderRow, it gets the original column header and not the custom header. Please help!!!

Why when I click on title header to sort a GridView, some data disappear?


 Hi there

When I click on my GridView header "End Time" all the rows which contain the string "N/A" disappear.
Here is my code:

protected void GridView2_Sorting(object sender, GridViewSortEventArgs e)
FillDataGridView_JobHistory(ViewState["DateBegin"].ToString(), ViewState["DateEnd"].ToString());

Note: GetSortDirection returns "endTime ASC" or "endTime DESC" and save in ViewState:

ViewState["SortDirection_JobHistory"] = sortDirection;
ViewState["SortExpression_JobHistory"] = column;

Then I fill the DataAdapter and use the ViewState info to sort it:

protected void FillDataGridView_JobHistory(string dateBegin, string dateEnd)
string query = "dbo.GetJobHistory";
DataTable dt = new DataTable();
SqlConnection myConnection = new SqlConnection(WebConfigurationManager.ConnectionStrings["ConnString"].ConnectionString);

SqlCommand cmd = new SqlCommand(query, myConnection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(new SqlParameter("@dateBegin", SqlDbType.DateTime));
cmd.Parameters.Add(new SqlParameter("@dateEnd", SqlDbTyp

Gridview Header & table data alignment problem



Newbie to ASP.net. Programming in C#.

I'm querying a SQL database and displaying the results in a gridview.

The results can be many records so I need to provide the facility to scroll. To display the headers when scroling I have implemented ( in my asp code) the headers in another table and the data is in another table. I see now I cannot align the column headers with the table data.

Appreciate any help to fix this issue.

If this method is not a good one to display headers with data please suggest another method.( Some example code guidance would really help)

Here is my ASP code.

<div id="divProjectTableHeaderFullDetail" runat="server" style="background-color: #993300;
            height: 40px; width: 770px; margin: 0;  padding: 0 ; " >
            <table style="font-family: Arial; font-size: 10pt; color: white;" cellspacing="0"

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