GridView - Row index shifted after adding another header row!

Hi all,

I have a gridview and I have add an extra header row in RowCreated event.

----------------------
Code:

Dim headerCell As TableCell = New TableCell
Dim rowHeader As GridViewRow = New GridViewRow(-1, -1, DataControlRowType.Header, DataControlRowState.Normal)

headerCell.ColumnSpan = 3
headerCell.Text = "Hello"

rowHeader.Cells.Add(headerCell)
grid.Controls(0).Controls.AddAt(0, rowHeader)
----------------------

.....row binding is ok, I can see everything correctly displayed....

....However, when I try to loop the rows in the grid, there is nothing in row=0 and what suppose to be in row=0 all went to row=1, all the rows have shifted one index down......the row count is correct and the last row just disappeared, anybody know what cause that and how to fix it???

0
echeng_survival
10/16/2006 10:40:17 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
1069 Views

Similar Articles

[PageSpeed] 7

Hi,

adding rows at that stage is very likely to have that effect. Instead, do it at render stage (for example in overridden Render method on Page) when all the logic related to deal with grid's control structure has executed.


Thanks,

Teemu Keiski
Finland, EU
0
joteke
10/17/2006 9:43:45 AM
thanks, I'll try that..
0
echeng_survival
10/17/2006 4:33:52 PM
Reply:

Similar Artilces:

gridview control in another gridview control
Hi ia have a questioni have a gridview control which contains button in one colum.now my question is i need another gridview to be placed in the  first gidviewso that when i click on the button the second gridview will populate the data.now my question is how to place second gridview in first gridview.or is there any approach like first grid itself acting as parent and child.please help me  Hi sirikalavalapalli:                I think nested gridview will help you. Check this link and it will show you how...

Gridview control embedded in another gridview control
I am writing an ambulance crew scheduling application on the web and I need some help completing the last part.  I have an access database that has three tables: user table, shift table (describing the shifts available), and a schedule table (that stores shift by shift_id and user by user_id).  I have a gridview control that will display the available shifts but I cannot get the embedded gridview control that will display the user that is signed up for each shift to display because I cannot figure out how to use the OnRowDataBound method.  I need a simple VB example of how to...

There is a Gridview Control in the tmplate field of another GridView Control.
    For instance,a gridview displays the information of the  students in a class.A table is recording the information except their mark.There is another table recording the mark of the students whose foreign key is the primary key of the previous table.   string strSQLconnection=".................."; SqlConnection sqlCononection=new SqlConnection(strSQLconnection); SqlCommand sqlCommand=new SqlCommand("select * from stuendent where classID=1",sqlConnection); SqlConnection.Open(); SqlDataReader reader=sqlCommand.ExecuteReader(); GridVie...

Data presentation control in another Data presentation control
 Hello,I want to make a menu with datalist or gridview control.Basically,the menu will be like this,Categories     Sub Categories.For example, for COMPUTING category there will be NOTEBOOKS DESKTOPS etc.There will be a image for CATEGORIES and linkbuttons with Subcategories.If I put a datalist inside a datalist and a link button inside the second datalist visually it satisfies my need.However,CommandArguments come from database to linkbutton.Andwhen one of these command buttons is cliked it must go to proper page.I dont know how to wrie an event_handler ,specifically, for...

GridView's data sent to another GridView control on another page
I'm trying to get send a Gridview1 control's DATA on page1.aspx to Griedview2 on page1.aspx. I tried adding to a session varible like so:page1.aspxSession["gridsData"] = GridView1;page2.aspxif (Session["gridsData"] != null){    GridView2 = ( GridView )Session["gridsData"];}When page2.aspx loads, GridView2 does not display data. There is data there, because it is NOT null in the conditional statement. Is this the best solution??Thank you,Edski Use the data itself, not the Gridview, also, I would use the cache object instead of sessionDav...

Adding controls to header cells of auto generated GridView columns?
I have an application where we are dependant of the automatically generated columns in a GridView. The GridView is configured with paging and sorting. Now I need to extend the GridView with possibilities to add controls into the header row cells. What would be the best way to do this extension of the GridView? Basically I would like to add a LinkButton or ImageButton next to the auto-generated link that is the column name used for setting the sort order. I did some tests adding controls to the header cells when the header row is databound and also in the PreRender step and then I can ge...

GridView Cell Index and Control Index
How to find the grid view cell index and control index Where are you trying to do this from and what are you wanting to do?  Are you looking to find the cell index of a control inside of a gridviewrow?  ~Ben please can you  elaborate yr question in more detail... do you want selected rows index and cell or some selected control's row and cell index in gridview ?Thanx, [KaushaL] || BloG || Profile || Microsoft MVP"I would love to change the world, but they won’t give me the source code"Don't forget to click "Mark as Answer" on the post that helped yo...

GridView "Index out of Range" After Adding Calender Control Parameter
Strange behaviour and I can't find anything on the web about it...1) Things were working perfectly until I added in a Calendar control and set it as a DataSource param2) I ran Profiler and the SQL code works and the Gridview populates successfully after the calendar's SelectedDate is chose3) The problem is in the OnSelectedIndexChanged event. The basic problem (code omitted here just to show the main settings):<asp:gridview OnSelectedIndexChanged="gvVideos_SelectedIndexChanged">(code omitted)<asp:CommandField ShowSelectButton="True" ButtonType="Button" SelectText="Submit" />(code...

Adding an image control to another image control
I have a panel in a web form and have added a image control too it. Then I set the url to a picture. I then added a smaller image control to the first image control and set the url to a different picture. The problem is that the second control does not show a new picture. Can you not add an image control to another image control or does the parent image control display over the child image control?    I think you can do somthing like that with divs and diddling the z-index: http://forums.devx.com/showthread.php?t=6930I love ...

adding a control to a placeholder in another user control
hi all, i have a menu user control and a breadcrumb trail user control. i'd like the menu user control to add hyperlinks to an asp:placeholder inside the breadcrumb trail user control. how can i access the breadcrumb user control from the menu user control? Hi, you can use Parent.FindControl("nameOfTheBreadCrumbControl") (or use Page.FindControl("") ) to get to the breadcrumb control. Cast it to the class of the breadcrumb and then have a property on the breadcrumb that you can use to alter the control (add another link to the breadcrumb). Another way is like...

Header text dissappears when image is added to the header of a GridView
Hi, I am using a gridview where i am trying to add image to header of a gridview and i have to call JAVASCRIPT funtion on  image click . When the gridview is rendered the image appears and i can call the JAVASCRIPT function too , but the Header text dissappears. This occurs only when the the Sort expression is not given to the columns. That is column are not sortable. For column that are sortable the image as well as the Header Text appears. I am not getting the exact reason behid that.. I am attaching the code that i am using. Please help me out. This is very urgent... Thanks i...

Edit data with GridView Control ? or another control ? help
I use GrivView in ASP.Net 2.0 to show data from DataTable. And i want to edit some fields in some rows. How can I do it? If i touch EDIT button - all columns, which have ReadOnly=false, switch into EDIT mode. But I want, that in first raw I can edit 2,3 column and in second row only 3 column. How can I do it ? ...

GridView (or another GridView like control) with built-in insertion
HelloDoes anyone know how to insert rows within the GridView. I have tried using the FooterRow which works but the FooterRow does not show when there are no records in my data source. Does anyone know either an EASY way to get a FooterRow to ALWAYS show even where are no records in the data source. Has this problem been fixed in Orcas? I see Microsoft have yet to see the light to add built-in insertion capabilities to a GridView. Otherwise, are there any other controls that are similar in functionality and use to a GridView that have built-in insertion capabilities (through something l...

adding data from another control to detailview control then saving
Ok the answer to my problem may already be here but I was not able to find it.  If anyone knows the answer or the link to post that has the answer I would greatly appreciate your help.   I have a detailsview control which during "Insert" must recieve a value from another control which is not part of the detail control.  I have been able to accomplish this by changing the the field I need to a template then playing with the binding.  The problem arises when I attempt to save.  The field no longer actually binds to the database so I am unable to get the data to the d...

Get controlID from control (textbox) inside another control (gridview)
Ok, so I've been trying to get a link within the edit item template of a gridview to open a new window.  I can do that fine, but when I try to pass the new window the controlID of the textbox to pass the value back to in the originating page I can't get the correct ID.  (that was a mouthful)  Maybe my code will explain better...  <EditItemTemplate> <asp:TextBox ID="EndTextBox" runat="server" Text='<%# Bind("endtime") %>'></asp:TextBox> <a href="javascript:;" onclick="window.open...

Help Req: !!! :- On Disabling Controls Present inside a Gridview control
Hi All, We have A requirement Where we have disable controls inside a grid.These controls can be textbox, DropDownlist (in TemplateField), ComandField present inside the grid.We have to call a generic method for doing the same .(since it can be done for multiple grid.) PFB the code snippet we use. Which disables all the controls inside the page.The bolded part of the code is used to loop inside a grid view.(Not Working.)Is this ideal way to deal with the requirement.Or can someone suggest be a better way.        public void DisableMe(Page p1, st...

GridView: image is added under the header text instead of in front of it (same level as the header text)
 Hi,I have a boundfield in my gridview like this:                                        <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name">                                 &n...

GridView Control Header
Hello, I have a GridView Control with a column X.  I want the header of column X to be a value taken from the same query that populates the GridView control.  I have tried putting '<%# Bind("FieldName") %>' in the Item header but it doesn't show. Any help would be much appreciated   Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound If e.Row.RowType = DataControlRowType.DataRow Then If e.Row.DataItem("Notes") = "test" Then Me...

header in gridview control
Hi all I am using dataview control and and using datareader as data source. jobsRs = DBFunctions.MyReader(strSql) GridView1.DataSource = jobsRs GridView1.DataBind() By default heading of each column is the field name in the database. How i can write my own column headings not the field name from database. Thanks  You must set the GridView.AutoGenerateColumns property to False and specify the columns collection yourself. Using BoundFields or TemplateFields, you can simply set the HeaderText property to the column heading of your choice.Thanks, EdMicrosoft MVP - ASP/ASP.NET ...

How do I control one control from another control?
I have a page page1.aspx which is within a master page. On page I have a table with two cells. Within each cell I have placed two controls (ascx) that I have developed. Now I'd like to be able to get these two controls to interact. One needs to update the other. One has some search criteria that the other one needs to update its gridview. One needs to make the other visible/not visible at certain times. Out of the box neither control can see each other at all. Is there a good article or someplace I can find some information on how to do this?  AllAboutFocus.com. Information Technolo...

Adding a Gridview Control
Hi there,  Im new to ASP.NET and im trying to develop a web application for a project. Ive downloaded and installed both VWD and SQL Express Edition. I have been following the VWD Guided Tour, and im having difficulty on Adding a Gridview Control: http://www.asp.net/Guided-Tour/s7.aspx  I am up to part 3, and under Select or Enter a database name, 'pubs' does not appear neither does 'model', however the other 3 do. I would extremely appreciate if someone could tell me how i can get the pubs database to appear from the list /and provide a solution to resolve this ...

Update other controls after a Postback has fired from another control - eg insert data
Hi This is a slight modification to the personalweb asp.net template which shipped with VS2005 I have a web form - linked to a master with two content placeholders left and right: #1 In the left i have a formview containing a textbox + button - and a datasrouce object with an insertmethod - this calls a method to insert the textbox data into table albums: #2 In the right  i have a gridview which has a datasource this has a selectmethod which calls a select method from table albums. Because i am using a maser template with two content placeholders i cannot use the same ObjectD...

want to call one c#.net function in one user control from another user control
hi i have two user controls info.ascx and personal.ascx i have a function like in info.ascx i have a function like showdetails() {   } now i want to access this function from personal.ascx can i do this ? thanks in advance. shwetaThanksshwetaIn a day when don't come across any problem -you can be sure that you are traveling in wrong path  you should better create a class where you will define the "functions" that you need in both files. declare "static" the function and call it like nameofclass.nameoffunction In a web project you can...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: http://forums.asp.net/t/1069245.aspx Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Master Details in two seperate GridView Controls
I am simply trying to have a list of people in the top grid control (works fine), then when selected have the second Grid Control show details for that person(not working). Here is what I am trying from the load event: Sub BindData() Dim myConnection As New MySql.Data.MySqlClient.MySqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionSql")) Dim strPersonSQL, strActSQL As String strPersonSQL = "select row_id, first_name, last_name, middle_initial, dsi_id, created, created_by, program_of_study, email from tbl_person" Dim myPerCommand As New MySqlClient.MySqlComm...

Web resources about - GridView - Row index shifted after adding another header row! - asp.net.presentation-controls

GridView SelectedItem Binding Gotcha in WinRT
Last night when I was doing some WinRT hacking I was trying to setup databinding to the selected item in the GridView control and I ran into ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Advanced Search Gridview Latest News Releases All ...

CNW Group
... Services Beyond the Wire About CNW my CNW CNW Access CNW Directories Financials Webcasts Events my CNW All News Releases Advanced Search Gridview ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Add a Filter Gridview Latest News Releases All Today ...

New CmdLets of Powershell 2.0
New CmdLets of Powershell 2.0

Price Drop: Softbox
... objects- create product reflection- changing the background with something more interestingUse it as:- softbox- honeycomb softbox- gridview ...

Profile.aspx: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 25 Oct 2012

DotNetKicks.com - Upcoming stories
DotNetKicks.com is a community based news site edited by our members. It specialises in .NET development techniques, technologies and tools including ...

View Features - ExtendASP
Call 847-681-9827 or Request a Demo View Features Testimonials Pricing About Us Coming Soon ExtendASP exposes every feature, more than any other ...

Resources last updated: 2/16/2016 8:29:22 AM