Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_professional thread: Generating Colums Dynamically


Message #1 by bushra saleem <buchoo_2000@y...> on Fri, 13 Dec 2002 12:23:59 -0800 (PST)
I am  generating 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     
                                          



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

  Return to Index