PC Review


Reply
Thread Tools Rate Thread

Creating TemplateColumn in Codebehind

 
 
=?Utf-8?B?S3J6eXN6dG9mIEthcm5pY2tp?=
Guest
Posts: n/a
 
      14th Feb 2005
Hi,
I need to create DataGrid with TemplateColumns in Codebehind
so I do something like that:

TemplateColumn templateColumn = new TemplateColumn();
templateColumn.HeaderText = "header title";
TemplateBuilder templateBuilder = new TemplateBuilder();
templateBuilder.AppendLiteralString("text" );
templateColumn.ItemTemplate = templateBuilder;
DataGrid1.Columns.Add(templateColumn);
so I have new column with "text" string in every row of this column. How
could I define, so I will have in this column some literal text, as this
"text" and also data from DataSet which I've bound to DataGrid1... when I try
to:
templateBuilder.AppendLiteralString("<%# DataBinder.Eval(Container.DataItem,
\"columnName\") %> text" );
it dosen't work as I want to, becouse .NET treaded this like literal control.

Regards,
Krzysztof Karnicki


 
Reply With Quote
 
 
 
 
jdlwright@shaw.ca
Guest
Posts: n/a
 
      17th Feb 2005
Hi, TemplateBuilder is a Siren, she lures you into the rocks and then
irritates you as you try and fail to get it to work...!

Check out this
http://msdn.microsoft.com/library/de...mmatically.asp

It's really much simpler than it first looks, basically you hard code
your databinds into the InstantiateIn override.


Jim

 
Reply With Quote
 
Sherif ElMetainy
Guest
Posts: n/a
 
      18th Feb 2005
He is asking about a completely different thing
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi, TemplateBuilder is a Siren, she lures you into the rocks and then
> irritates you as you try and fail to get it to work...!
>
> Check out this
>

http://msdn.microsoft.com/library/de...mmatically.asp
>
> It's really much simpler than it first looks, basically you hard code
> your databinds into the InstantiateIn override.
>
>
> Jim
>



 
Reply With Quote
 
jdlwright@shaw.ca
Guest
Posts: n/a
 
      18th Feb 2005
No - I dont think he is asking about a completely different thing. My
understanding is, he's asking how you get TemplateBuilder to
'recognize' or work with databound values - quote;

"How could I define, so I will have in this column some literal text,
as this
"text" and also data from DataSet which I've bound to DataGrid1... when
I try
to: templateBuilder.AppendLiteralString("<%#
DataBinder.Eval(Container.DataItem,
\"columnName\") %> text" ); "

The article I posted shows how to solve this, I know because I had just
been searching for a solution to the same problem, and after I found
the solution I was nice and posted the solution to the most recent
question on usenet/google-groups, because I hadn't found the solution
on there.

Maybe if you have a different interpretation of his question, you'd
like to share it?

Jim

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Datagrid TemplateColumn Jake K Microsoft ASP .NET 1 9th Jan 2007 05:35 PM
Create TemplateColumn for DataGrid in codebehind (vb.net) ? =?Utf-8?B?VGlncm91?= Microsoft ASP .NET 2 30th Nov 2004 09:59 AM
Create a TemplateColumn for DataGrid in codebehind (vb.net) ? =?Utf-8?B?VGlncm91?= Microsoft ASP .NET 0 27th Nov 2004 02:53 PM
TemplateColumn Dave Microsoft ASP .NET 1 3rd Oct 2004 12:48 AM
<asp:TemplateColumn > =?Utf-8?B?RGFz?= Microsoft C# .NET 1 19th May 2004 10:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:45 PM.