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

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

GridView - putting TemplateField fields in between data bound fields

Posted By:      Posted Date: September 26, 2010    Points: 0   Category :ASP.Net

Here is my problem.  I have a GridView, and I want Column1 to be equal to datatable data (filled by a SqlDataAdapter).  Then I have two other fields by the SqlDataAdapter (first name, last name), and I want to have those two fields combined to form Column2.  I have a TemplateField for my GridView that combines the first name and last name with Eval()'s, but the GridView places this combined field TemplateField and puts it as the first column.

How can I do this so that TemplateField can go in between fields that are databound?  Thanks in advance. :)

View Complete Post

More Related Resource Links

Putting data from a variables into a compaq sql database row of fields?

Hi everyone,  I have not used database in two years and have forgotten how to set one up completly. I have made a compaq databse 3.5 and have built the columns. I know how to put the data in manualy. I watched the Video on database and it showed how to bind controls to the datbase but it gave no method when you have the data in variables.  What I have is 7 variables some are using arrays and some are made up from data in  the arrays. I need to populate the db with the data in these variables at the time when my applications has the data ready. I have the connection set up and it does open and close the connection but every search I have made has used binding to bind database to a control that has the data in it.  What method would be the best to use performance wise? Could you point me to an example of this method? CurtisAlways Lost in Code, Always mark answers as correct if they answer you question and solve your problem. This way others when searching for similar problems can find the answer faster.

Create ID (uniqueid?) from two fields when data is entered


I need to create an ID from two fields when they are entered into the db for the first time.  I thought Uniqueidentifer would do this, but it looks like uniqueidentifier is random and i have no control of the process. 

My user will enter 4 letters into a column called INIT and 4 numbers into a column called NUMB.  What I would like to do is create an id by combining those fields.

How can I do this?



LINQ with GridView and edit fields


My project includes a grid view which displays information of inventory items (Assets), data is quried from AssetTable. The GridView has a command field to allow editing, below is a description of the tables and how data is displayed


BuildingTable: (BuildingID, BuildingName)

AssetTable: (BuildingID,..,....,....)


ItemTemplate: Using a LINQ query I join the two table and displays in a label control a string which includes BuildingID and BuildingName (5 North Building)

 EditItemTemplate: Using a LINQ query I populate a DropDownList with strings of BuildingID and BuildingName same as above.
Here  issue which I need to resolve:
1.  ItemTemplate display the correct information (BuildingID BuildingName) but when I switch to EditItemTemplate the pair that is 
displayed is the first one on the list, how do I make is scroll to the item which was displayed in the label ?
<asp:CommandField ShowEditButton="True" >
                    <ControlStyle Wi

Cutting Edge: Custom Data Control Fields


In ASP. NET 2. 0, the GridView and DetailsView controls are designed to work together. They don't merely provide complementary services, they also share a number of helper classes and components. The output of the GridView control consists of a sequence of rows, each with a fixed number of columns.

Dino Esposito

MSDN Magazine January 2006

Enable Go Button after entering data in all fields using javascript funtion


Hi friends,

My page is having one gridview with check boxes,two textboxes and one button just like this see this link now i want to enable go button whenever user has select checkbox in gridview and he needs to enter text in two textboxes. i have written onkeyup event for two textboxes to test whether user enter text in textboxes or not but i am unable to write javascript function to check whether user has selected checkbox in gridview or not to enable go button .My requiremnet is user need to enter three inputs select atleast one checkbox in gridview and he needs to enter text in two textboxes.please friends pls tell me how to write javascript function to find whether user has selected the checkbox in gridview or not

Linq join fields for return data


  how would I join fields together?

           return (from c in storedb.Product_Categories

                         where c.Category_Name.Contains(searchText)
                         orderby c.Category_Name
                         select new {
                                    c.Category_Key && " ;" && c.Category_Name // HOW CAN I DO THIS.....

Send an Email with User fields data entered in the form


Hi All,

          I have a form which have some user input fields(like textboxes,dropdownlists,textarea etc) fields and a submit button.

on click i need to send email with body contents as all the details entered by user in the form

Can anyone suggest how i should approach to this in sharepoint..

any code examples would be appreciated.


Importing SharePoint List Data into Project Server 2007 Custom Fields

Learn how to use the programmability features of Project Server 2007 and Windows SharePoint Services 3.0 to import SharePoint list data into an enterprise custom field.

How to query for id's of the fields with List Data Retrival Services Query() web service

Since i marked a post as answer in my previous topic, it seems that people dont visit the topic anymore as they see it as "answered" while it actually is only partially answered. So i guess i have to ask again in a different topic.    I need to get data from Sharepoint Server (3.0 i belive) for my Integration Services project. For that i use Sharepoint's webservices. I've read tutorials and downloaded sample programs to talk to WSS web services. I realise i have two ways to get items in a list: Use Query() or GetListItems(). Problem is, GetListItems() has a mandatory "Row limit" field and i might have to import ALOT of fields, so i thought Query() is better for me.  But, when using GetListItems(), the WSS returns the ID of the fields (for example, for a field of type user, something like "395;Ivanov Ivan Ivanovich" is returned) but when using Query() for the same list, WSS returns only the field value ("Ivanov Ivan Ivanovich") without the ID. I need it to return the ID as well. How can i set it up, on my side or server side, so i would receive the ID's, not only the values of the fields that are actually linking to something by ID when i use Query() web service?     

How to make Hidden Fields appear on every other page when there are other data regions exist on the

Dev Environment: Visual Studio 2008 Client reporting(.rdlc) I have a client report with one hidden field and one table. The data for the hidden field come from one dataset and the data for the table comes from another dataset. Since there is huge data on the report, the table data spans multiple pages. at the same time i want the hidden field to appear on every other page along with table. i'm using these hidden for report header purposes. As an alternative i have used hidden parameters instead of Hidden Fields. Are there any alternatives other than this ? -- Praveen

How to disable fields in a GridView when you change the listbox options?

 Hi all I am trying to apply the same logic I applied to a FormView. Here is what I do:I have a DropDownListBox as one of my FormView fields and when I choose a specific option the fields inside my FormView are enabled/disabled according to the options chosen. Well I havent been able to apply that concept to a GridView. Here is my code to the FormView:protected void ItemFormView_DataBound(object sender, EventArgs e) { DropDownList ddlConfigType = ItemFormView.FindControl("ddlConfigTypes") as DropDownList; if (ddlConfigType != null) { if (ItemFormView.CurrentMode == FormViewMode.Edit) { DisableNAFields_EditMode(ddlConfigType.SelectedItem.Text); } } }private void DisableNAFields_EditMode(string configType) { TextBox txtboxScope = ItemFormView.FindControl("txtboxScope") as TextBox; if (configType == "registry") { txtboxScope.Enabled = false; } } Is there a GridView mode enumeration? How do I achieve the same goal? Thank you

no data in gridview templatefield

I have a gridview bound to a objectdatasource, when I try to convert one of my columns to a template field the data doesn't displayBefore converting <asp:BoundField DataField="ID" Visible="false" /> <asp:BoundField DataField="Contract" HeaderText="Contract" /> <asp:BoundField DataField="Tender" HeaderText="Tender" /> After converting <asp:BoundField DataField="ID" Visible="false" /> <asp:BoundField DataField="Contract" HeaderText="Contract" /> <asp:TemplateField HeaderText="Tender"> <EditItemTemplate> <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Tender") %>'></asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("Tender") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> Im usig the option in the gridview smarttags Convert this field into a TemplateField . When run as a bound field the data appears, when run as as template the data doesn't, Is there something I'm missing?    

how to duplicate fields on form data source?

I have many fields with similar names and same type. Is there any easy to copy and paste and then change field names? thanks,

How to put Data in multi Taxonomy type fields using Datasheet view

Hi, We have a requirement where data has to be uploaded to a list having a Multi Taxonomy column.Is it possible to do so using datasheet view. Or please suggest if there is any other way. Thanks, Ash

Image to appear in gridview if two other gridview fields meet condition

Hi all-I'm populating a gridview with this query:Dim DataForGridview = (From p In Products _                        Join a In customerCategoryA On p.productID Equals a.productID _                        Join b In customerCategoryB On p.productID Equals b.productID _                        Select New With _                                { _                                .Product = p.product, _                            &

Auto-fill Title and other fields from a data View edit menu

How do I Auto-fill Title and other fields in a list from a data View edit menu. The Title and other current data should transfer from the data view row being edit. Can anyone point me into the right direction how to accomplish this? Thanks. Mike  

Gridview bounds fields I want to combine two of them ???



 I have a gridview on my page bound to an object data source which gets data from a table called "Sizes".

In Table Sizes there are "ShoeVersion" and "ShoeSize" Columns. So in the gridview when bound

there are 2 seperate lines.

<asp:BoundField DataField="ShoeVersionId"

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