Using the same DataGrid with two different DataTables and one column difference

I'd like to populate the same DataGrid from two different functions with one column difference. One of the DataTables that will be used has an extra column entitled description, where I'd use a template column or bound column. I know that if I try to do it now, I'll get the error "DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name Description. I tried using a label in the template column and disabling in the OnItemDataBound event. This obviously does not work. Is there a common way of doing something like this without having to create a whole second DataGrid with a one column difference?
5/13/2005 12:39:43 PM 72751 articles. 3 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 54

The easiest way to implement this is to add dummy column in your tabletable without additional field.

For example:

Select col1, col2,col3 ...., '' Description from TableA
Hide the column on ItemCreated.


Or you can add a empty TemplateColumn, On ItemDataBound add label control to it dynamically.



Richard Xin
MCAD(charter member),MCDBA,MCSD
Web Site: (For ASP.Net tips and Code snippet)
5/13/2005 4:13:34 PM

Thanks. Yes after I posted this I ended up getting the same DataTable for both and hiding a column for the one DataTable in the ItemDataBound event.


Thanks so much for the help!

5/13/2005 5:37:16 PM
One other thing. How would I get the value from the DataTable into the label in the ItemDataBound event if I wanted to do it that way?
5/13/2005 5:48:51 PM

I think I answered my own question on this one:

Label myLabel = new Label();

myLabel.Text = (e.Item.DataItem as DataRowView).Row[2].ToString();


5/13/2005 6:05:37 PM

Similar Artilces:

how do i link two different sitemap with the use of menu control in one .aspx file to two different hyperlink in the master page?
I have two menu control with similar file(eg.defect.aspx) in the master page, whenever i click the similar file(eg.defect.aspx) in either menu control, it will show both the menu control(eg.student menu and staff menu), but i only want to show only either one of the menu (eg,student menu only). Is there any solution to my problem? Am i able to use similar file(eg.defect.aspx) for two different sitemap and two menu control and only show one menu control. Hey, What should or should not be visible; the whole menu, or the selected field?  Are you h...

Combine Two Different Columns into one column
Hi Guys,   I have twotables(Employee and Borrower). In Employee table have EMPID and Borrower table have BorrowerID. I want to comebine these two columns into one column as EMPID  in Employee table. Can  any one help? Thanks what is realtion between to tables ?   Use    Union Thanks for reply. Acutally Employee table EMPID, NAME Columns. in this Employee table had 12000 rows. Borrower table has BorrowerID,BType etc.. .Here Employee ID and BorrowerID both are same. This table has 16000 rows. Now my what i want to do is Come EMPID and BorrowerID and ...

printing in two different printer for two different datawindows but from one screen
Hi all Our cilent has asked for facitly from a perticular screen that the two different report sholud be printed on two different printer from two different datawindows when a form is filled. First of all is it possible. and if possible pl reply. i tried to go by <DW Control Name>.Object.DataWindow.Printer but later after studying help file i come to know that this function is descibe onle i.e modify function can not be appled. Reagards Trilok Rawat Yes, it is very much possible....go to for printer utility. On Tue, 20 Feb 2001 04:37:...

Different datagrid columns for different situations
I have the following problem. Users with different user privilages must see only certain fields in the datagrid. For example the administrator can see three extra columns. (Boundclumns) Also for one datagrid I need to do the following. For administrator the firstname and surname columns must display as Firstname,Surname For normal users the firstname and surname columns must display as ******* and ********* How do you change the same datagrid for different situations? Thanks for any help. assuming you are using sql server, you can modify your query to filter it out fro...

How to get data from two different tables for two different columns of a gridview based on datakey
Hi All,            I have a Gridview with two different columns- "Faculty" coming from tblFaculty and "Teachers" coming from tblFacultyTeacherLink. I want to get data for "Teachers" by comparing FcaultyId in tblFacultyTeacherLink and then getting Teachers name. How to achieve this without using nested gridviews?  My .aspx Page is as-   <asp:GridView ID="gviewFaculty" DataKeyNames="FacultyId" AutoGenerateColumns="false" runat="server" Width="100%&q...

Different controls of one module on different tabs?
Hi there, I´m writing a custom module which will display a bunch of different views of data. So I´ve created one control for every view I need and so it works fine. I tried both, placeholder and keywords, to show these controls, but just because of the growing number of controls I have to implement some kind of navigation menu. So, as DotNetNuke allready has a menu which is used and which kan be skinned it would be a good way to use this menu for the different controls. But I was only able to put the whole module onto a tab. Is there a way to put different controls of one module onto diff...

Loading the two datatables from a dataset in to two different excel sheets using OleDbAdapter
Hi,   I have a problem now, I just created two excel sheets and I loading the data to a datatable in a dataset. If the rows are greater than 65536, then I load the remaining in the second datatable of a dataset. But while calling the update method of OledbAdapter after the first sheet get filled it throws error as "Spreadsheet is full". OledbAdapter.Update(dataset) or even I tried OledbAdapter.Update(datatable). Since i m not using insert query to insert in to the datatable. I have a dataset which I got from someother data and using that dataset i want to fill another ...

Binding different columns in a datagrid to different tables in the same dataset
Can it be done? Cheers Mark...

two menu controls required in one aspx page with two different sitemap file
dears,in vs2005 website how it is possible to add two menus with two different sitemaps ?? i did one menu control like as this menu is working fine with SiteMapDataSource1  and my requirement is i want to add one more menu control with another sitemap it possible to do that way?can anybody help me for this? <asp:Menu ID="Menu1" runat="server" BackColor="Green" BorderColor="Green" BorderStyle="Ridge"              &...

The new Firefox 3.5
Name: Daniel Email: bossennewpatgarrifuliodotmailexpiredotcom Product: Firefox Summary: The new Firefox 3.5 - when using same username for different sites with different passwords, when I save the password on one site, the one in the other site changes too. Comments: The new Firefox 3.5 - when using same username to log on to two different websites with different passwords, when I save the password on one site, the one in the other site changes too. I cannot save different passwords for same username on different sites. Hope you can fix this. Keep up the good work. Brow...

one control with two different types?
Hi all I am new to and I am trying to build a basic navigation control. The control should be able to render either a text version of my navigation, or a more graphical version. I would like to create a control that I can then instantiate as either a text version or a graphical version. Here is what I have so far for code in my ascx: Namespace NSS Public Class Menus Inherits System.Web.UI.UserControl Protected GraphicalMenus As Panel #Region " Web Form Designer Generated Code " #End Region Public Overridable Sub D...

Javascript acting differently on two different severs using the SAME browser
I have the following aspx page which on loading (<body onload="'Assessment.pdf'); location.href='user_area.aspx';">) is meant to direct the user to two places: open Assessment.pdf in a new window, and then change the window to user_area.aspx. This works perfectly on my development environment (everything hosted on localhost).  However when I publish to my server and view it through the SAME browser only the location.href='user_area.aspx' seens to fire completely ignoring the first line.<%@ Page Language="C#" AutoEventWir...

Any difference between two control classes in net 2005
I have a problem with net 2005, i have two controls having the same namespace (namespace is: Controls), the first control class's name is 'Controls_ToolBar', and the second control class's name is 'Controls_ToolBarSeparator'. In the first class, i declare a variable which points to the second class, but it give error. Following is my code:First control class:Namespace Controls   Public Class Controls_ToolBar      Inherits Controls.ControlBase      Private lastLabel As Controls.Controls_ToolBarSeparator = Noth...

Using one Update Panel for different controls
Hi, I have 5-6 controls span accross different TDs and TRs and i want to update all of them at the same time on certain action. Since they are all scattered in a table i obvioysly cannot just put all of them inside one ContentTemplate on design time. The only option i see is to use like 5-6 update panels for each control?? i dont think thats a wise decision. Please advice and give some suggestions. Thank You.  It depends on the amount of data contained in the table. If you don't have a huge table, put the entire table in a single updatepanel. Otherwise, it shouldn't be too b...

Web resources about - Using the same DataGrid with two different DataTables and one column difference -

Stack Overflow
Stack Exchange log in - careers - chat - meta - about - faq Questions Tags Users Badges Unanswered Ask Question Top Questions interesting 325 ...

University of Southampton - Wikipedia, the free encyclopedia
The University of Southampton is a British Russell Group university located in the city of Southampton , United Kingdom . The origins of the ...

London Metropolitan University - Wikipedia, the free encyclopedia
London Metropolitan University (London Met), located in London , England , was formed on 1 August 2002 by the amalgamation of the University ...

Google Chart Tools — Google Developers
This page has moved to Google Developers. Welcome! Learn more Dismiss Home Products Events Showcase Google Chart Tools Overview Hello Charts! ...

Google Chart Tools — Google Developers
Powerful, simple to use, and free.

AribaWeb ( - Google Groups
Search Images Maps Play YouTube News Gmail Documents More Calendar Translate Mobile Books Offers Wallet Shopping Blogger Reader Finance Photos ...

Linux Syscall Reference
Generated from Linux kernel using Exuberant Ctags , Python , and DataTables . Developed and maintained by Greg Ose .

... over one weekend where the author had a bit of extra time on his hands. Built with the help of the following tools: Bootstrap jVectorMap DataTables ...

A Map for the Microsoft Application Development Platform
... Localization N-Tier Remote Data Security Silverlight SQL Azure SQL Server Streaming XML Features ADO.NET DataSet ADO.NET DataTable ...

Application Development Framework
Articles: Application Development Framework

Resources last updated: 12/5/2015 10:29:28 PM