Bound columns and template columns in Gridview

Hello Everyone,

In my gridview, I changed some of the bound columns to template columns, I noticed that the template column is not recognized inside the RowDataBound event method. The reason I changed the bound columns to template columns so that I can add the total column in the footer. I guess I cannot do that with bound columns.
If I do e.Row.Cells[5].Text then  5th column is not recognixed inside the Rowdatabound event, but If i do e.Row.Cells[4].Text then  it is recognized. Please let me know what am I doing wrong.

<asp:GridView ID="dgAgentActivity" runat="server" AutoGenerateColumns="false" CellPadding="0" CellSpacing="1" BackColor="AliceBlue" OnRowDataBound="dgAgentActivity_RowDataBound" OnRowCreated="dgAgentActivity_RowCreated" ShowFooter="true">
          <Columns>
         
            <asp:BoundField HeaderText ="Time" DataField="SwitchTime" />
             <asp:BoundField HeaderText ="State1" DataField="TerminalState" />
             <asp:BoundField HeaderText ="State2" DataField="AgentState" />
             <asp:BoundField HeaderText ="Que" DataField="Queue" />
             <asp:BoundField HeaderText ="calculated Time" DataField="calculated Time"/>
              

            <asp:templatefield headertext="LogOut" >
           
                    <itemtemplate>
                        <%#Eval("LogOut", "{0:c}")%>
                    </itemtemplate>
                    <footertemplate>
                        <asp:label id="TotalTime" runat="server"/>
                    </footertemplate>
          </asp:templatefield>
             <asp:BoundField HeaderText ="test1 DataField="Not Ready" />
       
             
          </Columns>
         
         
          </asp:GridView>

           
   protected void dgAgentActivity_RowDataBound(object sender, GridViewRowEventArgs e)
    {

     }

Thanks.

0
vinki
4/25/2007 12:07:06 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

1 Replies
978 Views

Similar Articles

[PageSpeed] 32

Hi vinki,

As a short answer, when you have a bound field, the appropriate text is added to the cell when it is databaound.  When you have a template field, the appropriate controls are created and added to the controls collection for that cell.  You can still access them.  I'm sure there are other examples here, but you can start with http://forums.asp.net/thread/1678655.aspx.

Hope that helps.

Aaron


Don't forget to click "Mark as Answer" on the post that helped you. This credits that member, earns you a point and marks your thread as Resolved so everyone will know you have been helped.
0
agolden
4/25/2007 2:16:29 AM
Reply:

Similar Artilces:

Issue with Template Columns & Bound Columns while updating the data in a GridView control
Hi, I'm facing the below problem (In general, ObjectDataSource is driving me crazy ! ) I have a simple gridview control and an ObjectDataSource is used to populate the grid. I'm trying to update a row and the corresponding tableadapter methods & stored procedure are in place. Each row has 2 checkboxes and 2 textboxes in edit mode. When the change the values in edit mode and hit update, the checkbox values changed are saved into the Database properly, whereas the textbox values are not being saved. If the textbox column is a bound column then the column is updated with <NULL> in...

remove a gridview column dynamically, removes controls in template columns
I have a interface with a treeview and a gridview. The gridview has two templatefields that handles insert/update/deletes. The gridview is handling editing of different tables so I create the other columns in the gridview dynamically as boundfields. The user selects the table to edit in the treeview. The problem I am having happens when the user selects a table to edit the second time. The code that executes removes all bound fields, (dynamically added when user selected the first table in the treeview), but not the two template fields, and then adds boundfields specifi...

in a grid how to find a particular column is bound column or template column
hi,  Any one know how to find a particular column is bound column or template column or button column,etc in a grid Advance thanks   hi...use this dim label1 as Label=ctype(GridView1.FindControl("name"),Label) Hope This HelpsBhaaratRemember to click "Mark as Answer" on the post that helps UMy Blog find a particular column is bound column or template column no to find that particular column  Hi,please excuse me if iam wrong.i found that bount columns values are directly renders to a <td>  where template columns create some cont...

Can Unbound templated controls in a Gridview Update a bound column?
I have a list of stuffed integer words representing several pieces of data. My datasource has two colums - ID and DATAWORD and I want to present the user with a couple of Dropdowns and checkboxes showing the unpacked data for that row. I have done this by populating my unbound controls in the row.databound event  and it works How do I go about Updating the DATAWORD from my unbound controls?  Any pointers to articles that address this would be much appreciated. Thanks   Bill I have a GridView that populates a CSLAObjectDataSource from unbound data.  When the...

converting Bound Column to Template Column
Hi All, I wanted to convert the bound column in the grid to Template column. How could I do this dynamically? I know it can be done using the edit column dialog box, but I need to do that in the code behind. waiting for your reply. Thanks, regards,   Hi Techwork, Not tested and incomplete but just to get you going: Iterate the Columns property and find the BoundField with:Columns[i].GetType().Name == "BoundField" and((BoundField)Columns[i]).DataField == ... Remove this BoundField from the Columns Collection with:Columns.RemoveAt(i); Create a new TemplateField insta...

DataGrid: Bound Column vs Template Column
I have a datagrid with a bound column and a template column as given below.When I scan through the grid, I get the value of the first column (bound column). However, I cannot get the value of the second column (Template Column). I can see the data in both columns though.////////////////////////////////////////////////////////////////////////////////////<AlternatingItemStyle BackColor="#e0e0e0"></AlternatingItemStyle><Columns><asp:BoundColumn DataField="Facility" HeaderText="Facility"> </asp:BoundColumn><asp:TemplateColumn HeaderText="Facility2"><ItemSty...

Template column control for gridview
 Hi, I'm trying to create a web server control to use as a template column in a gridview, i want to use the data binded in the gridview as source, so far i haven't been able to do it. Anybody can get me an example of how to do this, or point me the classes i should extend, interfaces i should implement.  Regards,LFonseca  HiWhat exactly you want? HaresHClick here to Visite My SiteIf you want to be successful, be shamelessIf this will not help you out from your problem then please do not Mark As Answer Hi, Lfonseca:You can achieve this by define your ...

Problem: Template Column Converts To ( Bound ?) Column On PostBack
I have a template column in a datagrid and I have a button that allows the user to copy data from the second column into the template column, though when the user hits this button the template column converts to a bound column (or what appears to be a bound column). Any ideas how to resolve, thanks. Is there a different function for updating a template column ?For copying data form a bound column into a template column I am using this function:foreach(DataGridItem dgi in DataGrid1.Items){dgi.Cells[3].Text = dgi.Cells[4].Text;}...

When is a column not a column?
I have several extremely similar datawindows that I have to maintain that go against the same table. Recently, I had to add a column to that table, and also add the column to ALL of these datawindows that go against this table. I added the column to the first datawindow, set up the edit control style, etc. I then did a copy/paste of the columns edit control to the remaining dw's (of course remembering to first add the column in SQL). Everything (update props, column specs, column props) seems to indicate that the pasted column is linked to the column I selected, HOWEVER, when I...

Dynamically adding column to GridView kills existing template columns
I have a gridview with two template columns that were added at design time.  Each template contains an Item template which just displays the value and an Edit Item template that provides a drop down list during editing.  These columns work fine.  I would like to add a simple display column that is added to (or removed from) the grid when a user checks (or unchecks) a checkbox.  I've done this by adding the following code to my page_load rountine: if (chkAddFieldOffice.Checked)// {BoundField NewField = new BoundField(); NewField.DataField ...

Conditional Controls In Gridview Template Column
I have a Gridview which is editable. I want to be able to programatically present the control in the editable field i.e. Display a DropDownList or a custom control instead of a TextBox and this decision is to be made based upon a hidden field in the DataSource. Can this be done and if so how? It can certainly be done. I suggest creating a user control with a TextBox and a DropDownList on it. Only one is made visible through a property of the user control, and both allow reading and writing to a second property (the editable field value). You can bind both properties in the GridView. ...

Setting Datagrid Column to invisible when Column is an AutoGeneratedColumn NOT a bound Column
Hi all, Just like the title says, I'm trying to set a column to invisible but I'm unable to do so. If I bound the column I can used the code: me.datagrid.Column.Item(1).Visible = False But since I'm wanting the column NOT to be bound (there are a number of sql scripts that populate the same datagrid so I cannot bound all the columns since the columns are different for each script etc etc etc) how do I set an AutoGeneratedColumn to invisible?? Please help! Andrewwww.codingmayhem.com - VB.NET, C#, Silverlight, Javascript, HTML, CSS, T-SQL, MySQL and SQLitewww.headshot...

How to access GridView hidden Column value by clicking a template column button?
Hi: My GridView contains(for simplicity sake) three columns: a hiden template column that contains the DocID (the DataKey), a template column that contains DocTitle and a template button column that contains a button called btnDetails. When the GridView is loaded with data, the user may click the button on a row and obtain the DocID from the hidden column of that row. This seems to be simple enough. However, when the button is clicked, the GridView always returns blank. Any idea why this happens? My code is as follows: ASPX <asp:GridView ID="gvList" runat=&...

Template column control not Visible in all Gridview rows
I got something odd here.  there is too much code to post, but I have a Template column in a GridView (created in design mode) with a RadioButtonList as the control in that column.  But RadioButtonList does NOT exist in all rows!!!  It shows in some rows.  I am not tinkering with the Visible property.  Oddly enough though, the rows it doesn't show in are the rows with partial data (some dataitems are emptystrings).  But that deosn't make any sense to me.  Anybody seen this before?    jP  I believe you need an e...

Web resources about - Bound columns and template columns in Gridview - asp.net.presentation-controls

Template - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Facebook page template & tips for 2014
As Facebook page admins get started with 2014, the social marketing experts at ShortStack created a detailed template , including image sizes, ...

X'mas SMS Templates on the App Store on iTunes
Get X'mas SMS Templates on the App Store. See screenshots and ratings, and read customer reviews.

Web sketching template - 6 pages - Flickr - Photo Sharing!
This is a template in A4 that I have made inspired by the one of Brandon Schauer from Adaptative Path (http://brandonschauer.com/downloads/CanUX_bschauer.pdf). ...

United Airlines accidentally sends letter template to unhappy passenger
A US air passenger may have received what is quite possibly the world’s least sincere apology letter.

TV Templates - Transcripts
Lorem ipsum dolor sit amet, aihiad adaph dpas, osaf das. Oi asdfpo ijafj ai.

Springpad for iOS updated with customized smart notebook templates
... , the popular personal organizer app, makes it even easier to stay organized with their latest update by introducing customized notebook templates. ...

Today’s apps gone free: Practice+, Templates for Keynote, Dr. Panda’s Mailman and more
... and packages. Dr. Panda’s Postman is available for free for a limited time. It has a 4.5-star rating with a total of 44 ratings. Templates ...

Windows 10 patch messing with your Office 2016 templates? Here's how you can get them back
... 10 patch has had some Word 2016 users cringing in despair. The patch, titled Cumulative Update KB3124200 , is causing the Word 2016 template ...

Templates, Insights and Dictation in Google Docs
Google's standalone web apps for Docs , Sheets and Slides now show a list of templates you can choose to quickly create a document, spreadsheet ...

Resources last updated: 1/4/2016 11:18:50 PM