Hi ,
 can anybody help me ?
I am trying Bind a collection to a datagrid.
 
The test code is as below
 
 " AutoGenerateColumns="false" ShowFooter="true" CellPadding="3" BorderWidth="1" 
Height="144px" Width="320px" runat="server">****************************************
 " AutoGenerateColumns="false" ShowFooter="true" CellPadding="3" BorderWidth="1" 
Height="144px" Width="320px" runat="server">  <asp:DataGrid id="grdEmployees" 
style="Z-INDEX: 101; LEFT: 136px; POSITION: absolute; TOP: 72px"
    runat="server" Width="320px" Height="144px"
     BorderWidth="1" CellPadding="3" ShowFooter="true"     AutoGenerateColumns="false"
     datasource='<%#empCol%>'>
       <HeaderStyle BackColor="#00aaaa"></HeaderStyle>
       <FooterStyle BackColor="#00aaaa"></FooterStyle>
       <Columns>
              <asp:BoundColumn HeaderText="Employee ID" 
                     DataField="EmployeeID" >
                     <ItemStyle BackColor="yellow"></ItemStyle>
              </asp:BoundColumn>
              <asp:BoundColumn HeaderText="Last Name" DataField="LastName" />
              <asp:BoundColumn HeaderText="First Name" 
DataField="FirstName"></asp:BoundColumn>

       </Columns>
       </asp:DataGrid>
*************************************
 
 
***********************************

Imports System.Collections.Specialized

Public Class WebForm1

Inherits System.Web.UI.Page

Dim col As System.Collections.ICollection

Public empCol As System.Collections.ICollection

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Protected WithEvents grdEmployees As System.Web.UI.WebControls.DataGrid

'NOTE: The following placeholder declaration is required by the Web Form Designer.

'Do not delete or move it.

Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) 
Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) 
Handles MyBase.Load

'Put user code to initialize the page here

Dim Emp As New EmployeeBiz

Emp = New EmployeeBiz

empCol = Emp.GetEmployees

' grdEmployees.DataSource = empCol

grdEmployees.DataBind()

End Sub

Public Class EmployeeBiz

Public EmployeeID As String

Public LastName As String

Public FirstName As String

Public Function GetEmployees() As Collection

Dim tmpcol As New Collection

Dim Emp As New EmployeeBiz

Emp = New EmployeeBiz

Emp.EmployeeID = "101"

Emp.FirstName = "Leela"

Emp.LastName = "Krishna"

tmpcol.Add(Emp)

Emp = New EmployeeBiz

Emp.EmployeeID = "102"

Emp.FirstName = "Prasanth"

Emp.LastName = "pp"

tmpcol.Add(Emp)

Emp = New EmployeeBiz

Emp.EmployeeID = "103"

Emp.FirstName = "Nisanth"

Emp.LastName = "Kulkarni"

tmpcol.Add(Emp)

Emp = New EmployeeBiz

Emp.EmployeeID = "104"

Emp.FirstName = "Salim"

Emp.LastName = "peerzada"

tmpcol.Add(Emp)

Dim xcol As System.Collections.ICollection

xcol = tmpcol

Return xcol

End Function

End Class

End Class

***************************************

 

Regards,

Leela Krishna


                
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!

[Non-text portions of this message have been removed]




------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to