473,585 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid - How to set multiple datafields to a single bound column?

9 New Member
Hi,
I want to set multiple datafields from a dataset to a single boundcolumn in my gridview, but I can't see any easy way to do this since the DataField property of the boundcolumn takes a single string that maps 1-to-1 to the relevant column in the dataset. I want to map three columns from my dataset to a single column in my DataGrid - is there any easy way I can do this, or am I going to have to get complicated?


*Please ignore the indenting - seems to be formatting issues*
Expand|Select|Wrap|Line Numbers
  1. E.g. (Currently displays in datagrid like this:)
  2. Product Type Category Category 
  3. Apple Fruit Fruit&Veg Fruits 
  4.  
  5. I want:
  6. Product Type Category
  7. Apple Fruit Fruit&Veg
  8. Fruit
  9.  
  10.  
Jun 25 '08 #1
1 4603
kshnbd
3 New Member
To use multiple fields in a single gridview column you have to use templatefield. try this.

Expand|Select|Wrap|Line Numbers
  1. <asp:TemplateField HeaderText="Category">
  2. <EditItemTemplate>
  3.      <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
  4. </EditItemTemplate>
  5. <ItemTemplate>
  6.      <asp:Label ID="Label1" runat="server" Text='<%# Eval("field1") + ", " + Eval("field2") + ", " + Eval("field3")%>'></asp:Label>
  7. </asp:TemplateField>

Regards,

Free Online Diary
Jun 25 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
7901
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the header of the datagrid in the "ItemDataBound" method of the grid. However, once, they are added in the grid, i seem to lose the event handler for the...
7
7673
by: Billy Jacobs | last post by:
I am using a datagrid to display some data. I need to create 2 header rows for this grid with columns of varying spans. In html it would be the following. <Table> <tr> <td colspan=8>Official Impact Summary</td> </tr> <tr> <td colspan=2></td>
2
9914
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell (multi-select without modifier keys). I got that working fine, but I also wanted to keep rows selected after a sort, which I do by storing the row's...
7
2249
by: TT (Tom Tempelaere) | last post by:
Hi there, I'm struggling to get the right event. I want to be notified of a change in a cell in a DataGrid made by a user. I need following information about the change: * the row index * the column index * the newly entered value I need this information to update another DataGrid. I have checked the
1
840
by: Amber | last post by:
The DataGrid allows you to make columns visible or invisible on demand - even edit and other special columns. This article will show you how it is done. Some developers have reported problems controlling the visibility of columns in the DataGrid control. The problem usually comes down to one fact. The DataGrid has a property called...
1
2628
by: carlor | last post by:
Hi there, I have a datagrid that is bound to a datasource. The grid has a hyperlink column and I want to generate the URL using the URL Field and URL Format String fields in the Property Builder. The problem I'm running into is trying to generate the URL with more than one URL Field entry. I need to have more than field but I can't figure...
6
3747
by: Ron L | last post by:
I have a dataset whose source is a SQL 2k stored procedure that I am trying to display in a datagrid. This datasource has 4 columns that I am interested in here, a text column and 3 value columns corresponding to permissions to certain data classes. I want to put the permission values in combo boxes in the grid and instead of displaying the...
6
1773
by: Doug Bell | last post by:
Hi I have a datagrid with a combo box, I need to populate the combo with data dependant on the record value. eg for record 1, field Warehouse = 2R so combo would allow selection of locations valid for 2R record 2 has Warehouse = 2M so combo on that row has a selection of locations valid for 2M I can set the combo datasource but can't see...
1
253
by: Steve Caliendo | last post by:
Hi, I am populating a DataGrid using an SQLDataReader. My question is: How can I change the properties of a column, or get the data from a field after the DataBind method? When I try to reference a column, I get the error that the index must be non-negative and less then the size of the collection. I know that there are multiple...
0
7908
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7950
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.