two db table column, one datagrid column

Dear all,

I have a db table which have two column, first name and last name.

Can I show them in one datagrid column?

Thanks

0
ad_dee
4/10/2005 6:07:24 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

7 Replies
776 Views

Similar Articles

[PageSpeed] 25

Yes you may. Through the usage of the TemplateColumn, yes. An example of this:

<code>
<asp:DataGrid runat="server" ID="dgSomeGrid">
    <Columns>
        <asp:TemplateColumn>
            <ItemTemplate>
                <%# DataBinder.Eval(Container.DataSource, "LastName") %>,
                <%# DataBinder.Eval(Container.DataSource, "FirstName") %>
            </ItemTemplate>
        </asp:TemplateColumn>
    </Columns>
</asp:DataGrid>
</code>

-- Justin Lovell
0
master4eva
4/10/2005 7:37:14 PM

Thank you ans,

But if I use other control such as textbox in that column, then what should i do ?

 

0
ad_dee
4/11/2005 3:02:11 AM

In the case of textboxes make something like this in <Columns> section of Datagrid:

<EditItemTemplate>
<asp:TextBox runat='server' id='txtFirstName'
Text='<%# DataBinder.Eval(Container.DataSource, "LastName") %>'>
</asp:TextBox>
</EditItemTemplate>

 


Gunnar Peipman

-- General Protection Fault
-- Illegal Page Fault
-- Not My Fault
0
Qnnn
4/11/2005 6:55:38 AM

Thank you for all of your ans

Orginally i think that text attribute is only allow one <%%> block, therefore I have this question.

Also, another possible solution is that using sql to combined two col of db table into single columns before filling into dataset!

0
ad_dee
4/11/2005 8:47:27 AM

Sure there is. Most SQL's has concatenation operators.

ORACLE:  CONCATENATE(Field1, CONCATENATE(' ', Field2)) as ResultField

MS SQL:  Field1 + ' ' + Field2 as ResultField

- Sten

0
Sten
4/11/2005 1:14:36 PM

Concatenating two columns works only if you don't want to let user edit the data. In the case of editing such field you have to know that what part of inserted name is first name and what part is last name. There are persons having two first names (or first and mid name) and also there are persons having lastname as two words.

Well, in this case you have on simple solution too, but you have to mention it in bold text. You can ask user to separate first and last name using some character, by example comma.


Gunnar Peipman

-- General Protection Fault
-- Illegal Page Fault
-- Not My Fault
0
Qnnn
4/11/2005 1:26:04 PM

Another alternative is to add a new column in the datatable (assuming you are using a datagrid) and set the Expression property.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemDataDataColumnClassExpressionTopic.asp

This approach is supposed to have less overheard compared to generating the calculated column on the database backend.


Remove "_no_spam" for sending email
0
dpl
4/11/2005 2:16:06 PM
Reply:

Similar Artilces:

Problem in retrieving data from two table when one column entry in each table are same but no column in these table match with each other
Hello there!,       First of all i have two tables . one acts as a master table and other one acts as a details table. Currently the ptoblem with my procedure is, i have entered two entries for one project in the Master table. and to briefly discribe those two entries in the master table , i have entered two entries in the Details table corresponding to the entries in the master table. Now i need to combine the master table entries and the details table entries for the same project which should give only two entreies. but my procedure gives four entries. Could yo...

Only one table column in n-columns presentation style
Hi all, I think it�s better to explain our problem with an example. Any idea to do this data (2 records): ID: 1 DATE: 19/01/2000 OBS: 11111111111 22222222222 333333 aaaaaaaa line444ae q qwe qweqee ID: 2 DATE: 19/01/2000 OBS: ad asdasda as fffffffffff hhhhhhh mmmmmmmmmPPPPPPPPPP ooooo on one DataObject (something) like: ************ ID: 1 DATE: 19/01/2000 OBS: 111111111111 aaaaaaaa 444ae 22222222222 q qwe qweqee 333333 ************ ID: 2 DATE: 19/01/2000 OBS: ad asdasda as PPPPPPPPPP ...

how to pull several columns info from db then display them as one column in datagrid?
I have difficulty to gether several columns info from db to display them as one column in datagrid. say I have a table which has columns: "name", "street", "address", "city", "state", "zip", "status", Ex: I want to pull "street address", "city", "State", and "zip" from that table then diaplay them as one column "Address" in the datagrid so that the datagrid will only have 3 columns to display --"Name", "Address" and "Status". How do I do it...

Retrieve Data from two tables columns in one DataList Control!!!
 Hi, There is a DataList Control to retrive Data from Database Table.I want to retrieve data from two tables columns in one DataList. How can i? Thanks in Advance  Asghar Ali Mohammed http://www.aliwebdev.com(Web Designer and Developer)Do not forget to "MARK AS ANSWER" on the post that helped you.  Can you give an example of what you want to achieve?Regards,PrashantDont forget to click "Mark as Answer" on the post that helped you. Hii...SqlConnection myConnection = new SqlConnection("Your connectionString");SqlDataAdapter ad = ne...

populating a column in one table with data in a column from another table?
Hi,I have one main table and multiple smaller tables, the main table consists of all the information gathered from the smaller tables, plus some other data. I've set primary keys for all the smaller tables and created a relationship where the primary key id matches an id field inside the main table eg. there's a smalltableid column in both the smaller table and the main table.some misc info:i'm using a dataset (should the key in the dataset be pointing to the main table, or the smaller one?)both relation and foreign key constraints are created (with no rules set)my problem is, the data from ...

Grouping two columns into one column with GridView
I would like to modify the default output of a gridview to group two columns into one column. This is probably best explained by example. So, lets say there is a simple gridview with the output something like this:Name           Description                           Date------------------------------------------------------------------Foo            Some description of foo     &nb...

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 ...

datagrid columns bound to columns from different tables
Hi, I have a dataset with multiple tables. Is there a way to bind each of the datagrid's columns to a column from a different tables? Thanks in advance! BR The bottom line, yes you can, but it would take some custom methods getting called from a template column and some other fancy tricks. But, the datagrid is designed and works best when it's given it's one datasource. If you need data from different columns in different tables, I would make a custom datatable that reflects the columns you need and use that custom datatable has the datagrid's datasource. Don't think of t...

how to split the content of one column in the objectdatasource into two parts and let them display in two columns in the GridView?
i combine the title and the body of one article and store it in one column in the database,but i want to show the title and body seperately in the GridView,how should i achieve this goal?thank you so much for your advice!!! you can write the logic of splitting the column into two (title and body) in the query itself by which you are filling the datasource..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 you.This credits that me...

Display Key columns and all columns for tables in one diagram
In Tools->Display Option-> Object View ->Table, you could choose to display only key columns, PK columns, top X columns or all columns for tables. But it applies to the whole diagram. I wonder whether we could do it on table level, say to display all columns for fact table but just PK columns for dimension tables so we could squeeze one subject area in one page. Thx, Richard Mei BMO Financial Groups Manually drag up the bottom of the table outline to show just the columns you want. -- Mike Nicewarner [TeamSybase] http://www.datamodel.org mike@nospam!datamodel...

display the sum of two datagrid columns into third column
hi... there..     i have a datagrid with columns named Price ,Quantity and total. now in the total column i  wanna display the prices which comes by multiplyiing the price and quantity (like  total=Price * quantity). I'm workin in asp.net +vb.net.                     may i knw hw can i do this.. plz write the code.. thanks.         Hi, do like this..suppose u have,        string ProductPrice = ...

column header to span two columns in a datagrid display
Is it possible for a column header to span two columns? If so how would this be done? Thanks In the ItemDataBound (or ItemCreated) check if Item is of type Header and if so - define the colspan property of the Cell object which you want to define the Colspan for and delete the next Cell from hte DataGridItem CheersBug [MCSD] Is it possible to span header column in design view only. using some kind of CSS. I'm using ASP,NET 3.5 and GridView...

Making hyperlink on one column in datagrid from values in other column
Dear friends,  I have columns in database: id, homepage (stores url of persons hompage), name. I want to display in datagrid in such a way that: Only name as hyperlink (hyperlink value to be retrieved from id value, so that direct link will not be available) will appear in datagrid. So, that when user will click on hyperlinked email, it should get redirect to homepage url i.e.<a href=redirect.aspx?id=1>John></a> Only john should appear in gridview and will be redirected to is homepage say www.xyz.com/john   Thanks If u mean, how to place the I...

Merge two text columns into one text column
Hi Everyone.. I would like to know what is the best way to merge two text column into one test column in the table. Thanks pbj ANY HELP PLS.. Are you using any front end application or unix or just the isql to merge two text datatype columns? If you are using any front end application then it should not be a problem to merge the two text datatype columns. ...

Web resources about - two db table column, one datagrid column - asp.net.presentation-controls

Want to preview our new DataGrid for Xamarin.Forms?
tl;dr Zumero.DataGrid is a Xamarin.Forms control for displaying data in rows and columns. If you would be interested in testing and previewing ...

Mad King DataGrid
This post is about scrolling in WPF and the egocentric DataGrid control. I’ll give the project background but if all you’re interested in is ...

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

Microsoft Silverlight - Wikipedia, the free encyclopedia
Microsoft Silverlight is an application framework for writing and running rich Internet applications , with features and purposes similar to ...

Flash Builder Plug-in for SAP Netweaver Gateway - Adobe Labs
Search Navigation Labs Home Wiki Home Technologies Alchemy Blueprint Camera Profiles and DNG Profile Editor Cirrus ColdFusion 10 DNG Codec Fireworks ...

Casaba Security » Products » X5s Testing Tool For Finding XSS Vulnerabilities
Security analysis, consulting, development and testing partners who understand your business strategy.

CodeGuru - Microsoft developers related ideas, articles, tips, tricks, comments, downloads, and so much ...
CodeGuru is where developers can come to share ideas, articles, questions, answers, tips, tricks, comments, downloads, and so much more related ...

Caliburn Micro: WPF, Silverlight, WP7 and WinRT/Metro made easy.
A small, yet powerful framework designed for WPF, Silverlight and WP7. It implements a variety of UI patterns for solving real-world problems. ...

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

license-discuss@opensource.org: 11636: first draft of license proliferation committee report
FYI,the first draft report of the OSI's License Proliferation Committee.To join the OSI's license proliferation discuss email list, send anemail ...

Resources last updated: 1/17/2016 2:08:04 AM