|
 |
aspx_beginners thread: Creating DataGrid at runtime
Message #1 by bushra saleem <buchoo_2000@y...> on Wed, 11 Dec 2002 07:28:40 -0800 (PST)
|
|
Hello,
I want to create the columns of the Datagrid at
runtime. When ASP.Net code is executed I get an array
which can have any number of values/elements. Based on
these value/elements I need to create column in the
DataGrid at runtime.
Please tell me it is possible and how can I do this as
I am v desperate.
Thanks In Advance
Huma
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
Message #2 by "Paul Riley" <rilez@t...> on Thu, 12 Dec 2002 11:04:35 -0000
|
|
The only way I have found to do it so far is to use a hash table and
manually append rows to the datagrid. I don't have any source code at
the moment but I will look around for some and see if I can see any. Try
www.datagridgirl.com - Sounds dodgy I know and looks blumming horrible
but it seems to be quite a good repository
-----Original Message-----
From: bushra saleem [mailto:buchoo_2000@y...]
Sent: 11 December 2002 15:29
To: aspx_beginners
Subject: [aspx_beginners] Creating DataGrid at runtime
Hello,
I want to create the columns of the Datagrid at
runtime. When ASP.Net code is executed I get an array
which can have any number of values/elements. Based on
these value/elements I need to create column in the
DataGrid at runtime.
Please tell me it is possible and how can I do this as
I am v desperate.
Thanks In Advance
Huma
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
Message #3 by bushra saleem <buchoo_2000@y...> on Fri, 13 Dec 2002 10:55:04 -0800 (PST)
|
|
Hi Paul,
Thanks for the reply. Actually I have found out as how
to generate columns dynamically but Now I am facing
another problem while doing so. You see I have an
Array of Objects that I bind with the DataGrid, now if
I specify the field/variable name in the datafield of
boundcolumn or itemtemplate it gives me an error that
the variable specified is not is the attached
datasource, where as it is present.
Here is some code of what I am doing
<%@ import Namespace="System.Data" %>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb"
Inherits="WebApplication1.WebForm1" buffer="True"
EnableSessionState=True%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<script language="vb" runat="server">
Private Sub Show_GetTasks()
Dim mybound As New BoundColumn()
mybound.HeaderText=column.m_strname
//column.m_strname is the name of the header(it works
fine)
mybound.DataField ="m_Summary"
//(This is the variable in the object array. this is
causing the problem, it gives me the error when the
DataGrid bind Error:unable to find variable m_Summary
in the given datasorce )
Tasks.Columns.Add(mybound)
Tasks.datasource=View_TaskList
//View_TaskList is an Array of object whose structure
is as follows, Using Quick watch when you click the
Array you will see the indices of Array all with the +
sign, clicking on each sign gives the variables and
their values.//
Tasks.DataBind()
Note: If I use static binding that is specify the
columns before hand then I am able to use the variable
by the following syntax <%#
(Container.dataItem).m_Summary%> Here it works fine.
Can you please help me as what should I do Thanks
--- Paul Riley <rilez@t...> wrote:
> The only way I have found to do it so far is to use
> a hash table and
> manually append rows to the datagrid. I don't have
> any source code at
> the moment but I will look around for some and see
> if I can see any. Try
> www.datagridgirl.com - Sounds dodgy I know and looks
> blumming horrible
> but it seems to be quite a good repository
>
> -----Original Message-----
> From: bushra saleem [mailto:buchoo_2000@y...]
> Sent: 11 December 2002 15:29
> To: aspx_beginners
> Subject: [aspx_beginners] Creating DataGrid at
> runtime
>
>
> Hello,
> I want to create the columns of the Datagrid at
> runtime. When ASP.Net code is executed I get an
> array
> which can have any number of values/elements. Based
> on
> these value/elements I need to create column in the
> DataGrid at runtime.
> Please tell me it is possible and how can I do this
> as
> I am v desperate.
> Thanks In Advance
> Huma
>
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> http://mailplus.yahoo.com
>
>
>
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com
|
|
 |