Ask a Question related to ASP.NET General, Design and Development.
-
Jeremy Chapman #1
Creating TemplateColumns for a grid at runtime
At run time I've added a TemplateColumn to a DataGrid.
Now I'm trying to add a Table control to the TemplateColumns's
HeaderTemplate and ItemTemplate.
In essence, I'm trying to do in code, the equilavent of this html:
<asp:TemplateColumn>
<HeaderTemplate>
<asp:Table>
<asp:TableRow>
<asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
</asp:TableRow>
<asp:Table>
</HeaderTemplate>
<ItemTemplate>
<asp:Table>
<asp:TableRow>
<asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
</asp:TableRow>
<asp:Table>
</ItemTemplate>
</asp:TemplateColumn>
Jeremy Chapman Guest
-
Creating DataGrid at runtime
I would like to create a DataGrid with headers and empty cells (e.g. 4 colums) that are editable when the user, for example, clicks a button at... -
Set column names to template grid at runtime
Hi all, I have datagrid on a C# webform. Users can choose a lookup table to read\ edit etc via selection from a dropdown list box. However I... -
Hidnig column in grid populated at runtime using DataSet
Hello, I cant seem to find a property or method to hide the ID colum in a datagrid column which is populated using a DataSet at runtime (no... -
adding validator control to editable data grid at runtime
I put this post up in framework.aspnet but it probably belongs here. The problem I am running into is that if you don't set those properties... -
Creating controls at runtime
Hi, I am trying to create a TextBox at runtime, using the following code with a CodeBehind-File: Dim txtBox As New... -
Justin Dutoit #2
Re: Creating TemplateColumns for a grid at runtime
I'm trying to do just that at the moment. It's a little involved. What you
do is put everything between the <HeaderTemplate> and </HeaderTemplate> tags
(not the tags) into an .ascx file, like a user control. Then
you load that file into your template column.
[url]http://www.dotnetbips.com/displayarticle.aspx?id=84[/url]
Trouble is, I find this method really slow. There's an alternative which is
even more complicated:
[url]http://www.dotnetbips.com/displayarticle.aspx?id=85[/url]
Let me know if you learn a way that performs well ...
Good luck
Justin Dutoit
"Jeremy Chapman" <Nospam@please.com> wrote in message
news:#jN9pIkUDHA.2456@TK2MSFTNGP09.phx.gbl...> At run time I've added a TemplateColumn to a DataGrid.
>
> Now I'm trying to add a Table control to the TemplateColumns's
> HeaderTemplate and ItemTemplate.
>
> In essence, I'm trying to do in code, the equilavent of this html:
>
> <asp:TemplateColumn>
>
> <HeaderTemplate>
>
> <asp:Table>
>
> <asp:TableRow>
>
> <asp:TableCell>
>
> </asp:TableRow>
>
> <asp:TableRow>
>
> <asp:TableCell>
>
> </asp:TableRow>
>
> <asp:Table>
>
> </HeaderTemplate>
>
> <ItemTemplate>
> <asp:Table>
>
> <asp:TableRow>
>
> <asp:TableCell>
>
> </asp:TableRow>
>
> <asp:TableRow>
>
> <asp:TableCell>
>
> </asp:TableRow>
>
> <asp:Table>
>
> </ItemTemplate>
>
> </asp:TemplateColumn>
>
>
Justin Dutoit Guest
-
Jeremy Chapman #3
Re: Creating TemplateColumns for a grid at runtime
I'm going to try the second solution. Looks like it could be a good one.
"Justin Dutoit" <anon@anon.com> wrote in message
news:OZ8JFElUDHA.1916@TK2MSFTNGP12.phx.gbl...tags> I'm trying to do just that at the moment. It's a little involved. What you
> do is put everything between the <HeaderTemplate> and </HeaderTemplate>is> (not the tags) into an .ascx file, like a user control. Then
> you load that file into your template column.
> [url]http://www.dotnetbips.com/displayarticle.aspx?id=84[/url]
>
> Trouble is, I find this method really slow. There's an alternative which> even more complicated:
> [url]http://www.dotnetbips.com/displayarticle.aspx?id=85[/url]
>
> Let me know if you learn a way that performs well ...
>
> Good luck
>
> Justin Dutoit
>
> "Jeremy Chapman" <Nospam@please.com> wrote in message
> news:#jN9pIkUDHA.2456@TK2MSFTNGP09.phx.gbl...>> > At run time I've added a TemplateColumn to a DataGrid.
> >
> > Now I'm trying to add a Table control to the TemplateColumns's
> > HeaderTemplate and ItemTemplate.
> >
> > In essence, I'm trying to do in code, the equilavent of this html:
> >
> > <asp:TemplateColumn>
> >
> > <HeaderTemplate>
> >
> > <asp:Table>
> >
> > <asp:TableRow>
> >
> > <asp:TableCell>
> >
> > </asp:TableRow>
> >
> > <asp:TableRow>
> >
> > <asp:TableCell>
> >
> > </asp:TableRow>
> >
> > <asp:Table>
> >
> > </HeaderTemplate>
> >
> > <ItemTemplate>
> > <asp:Table>
> >
> > <asp:TableRow>
> >
> > <asp:TableCell>
> >
> > </asp:TableRow>
> >
> > <asp:TableRow>
> >
> > <asp:TableCell>
> >
> > </asp:TableRow>
> >
> > <asp:Table>
> >
> > </ItemTemplate>
> >
> > </asp:TemplateColumn>
> >
> >
>
Jeremy Chapman Guest
-
Justin Dutoit #4
Re: Creating TemplateColumns for a grid at runtime
It's OK now, tks
Justin
"Justin Dutoit" <anon@anon.com> wrote in message
news:esTNQXwUDHA.1928@TK2MSFTNGP12.phx.gbl...directive> Would you help me with something- I'll show you the command-line compiler
> line followed by the code... I'm missing a reference or a 'using'one.> which 'Container' needs, maybe you know which one...
>
> csc /out::..\bin\templatecolumns.dll /t:library /r:System.Data.dll
> /r:System.dll /r:System.Web.dll ColumnTemplate.cs
>
>
> ColumnTemplate.cs:
>
>
> using System;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Data;
>
>
> namespace Quickshop
> {
>
> public class MyTemplateColumn:ITemplate
> {
> private string colname;
>
> public MyTemplateColumn(string cname)
> {
>
> colname=cname;
>
> }
>
> /************************************************** *****************
> ** As a template, the class must implement the following method **
> ************************************************** *****************/
>
> public void InstantiateIn(Control container)
> {
>
> LiteralControl l = new LiteralControl();
> l.DataBinding +=
> new EventHandler(this.OnDataBinding);
> container.Controls.Add(l);
>
> }
>
>
> public void OnDataBinding(object sender, EventArgs e)
> {
>
> DataRowView mydataitem = (DataRowView)container.Dataitem;
> LiteralControl l = (LiteralControl) sender;
> DataGridItem container = (DataGridItem) l.NamingContainer;
> l.Text = "<SPAN class=header>It is " +
> ((DataRowView)container.DataItem)[colname].ToString() + "!</SPAN>";
>
> // l.Text = "<SPAN class=header>It si " +
> // (mydataitem)["productnumber"].ToString() +
> // (mydataitem)["brand"].ToString() +
> // (mydataitem)["productname"].ToString() +
> // (mydataitem)["price"].ToString() + "!</SPAN>";
>
>
> }
>
> }
>
> }
>
>
> Cheers
> Justin
>
>
>
> "Jeremy Chapman" <Nospam@please.com> wrote in message
> news:e3GZ#YsUDHA.1692@TK2MSFTNGP11.phx.gbl...> > I'm going to try the second solution. Looks like it could be a good</HeaderTemplate>> you> >
> > "Justin Dutoit" <anon@anon.com> wrote in message
> > news:OZ8JFElUDHA.1916@TK2MSFTNGP12.phx.gbl...> > > I'm trying to do just that at the moment. It's a little involved. What> > > do is put everything between the <HeaderTemplate> andwhich> > tags> > > (not the tags) into an .ascx file, like a user control. Then
> > > you load that file into your template column.
> > > [url]http://www.dotnetbips.com/displayarticle.aspx?id=84[/url]
> > >
> > > Trouble is, I find this method really slow. There's an alternative>> > is> >> > > even more complicated:
> > > [url]http://www.dotnetbips.com/displayarticle.aspx?id=85[/url]
> > >
> > > Let me know if you learn a way that performs well ...
> > >
> > > Good luck
> > >
> > > Justin Dutoit
> > >
> > > "Jeremy Chapman" <Nospam@please.com> wrote in message
> > > news:#jN9pIkUDHA.2456@TK2MSFTNGP09.phx.gbl...
> > > > At run time I've added a TemplateColumn to a DataGrid.
> > > >
> > > > Now I'm trying to add a Table control to the TemplateColumns's
> > > > HeaderTemplate and ItemTemplate.
> > > >
> > > > In essence, I'm trying to do in code, the equilavent of this html:
> > > >
> > > > <asp:TemplateColumn>
> > > >
> > > > <HeaderTemplate>
> > > >
> > > > <asp:Table>
> > > >
> > > > <asp:TableRow>
> > > >
> > > > <asp:TableCell>
> > > >
> > > > </asp:TableRow>
> > > >
> > > > <asp:TableRow>
> > > >
> > > > <asp:TableCell>
> > > >
> > > > </asp:TableRow>
> > > >
> > > > <asp:Table>
> > > >
> > > > </HeaderTemplate>
> > > >
> > > > <ItemTemplate>
> > > > <asp:Table>
> > > >
> > > > <asp:TableRow>
> > > >
> > > > <asp:TableCell>
> > > >
> > > > </asp:TableRow>
> > > >
> > > > <asp:TableRow>
> > > >
> > > > <asp:TableCell>
> > > >
> > > > </asp:TableRow>
> > > >
> > > > <asp:Table>
> > > >
> > > > </ItemTemplate>
> > > >
> > > > </asp:TemplateColumn>
> > > >
> > > >
> > >
> > >
> >
>
Justin Dutoit Guest



Reply With Quote

