Wrox Programmer Forums
|
.NET Framework 2.0 For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 21st, 2008, 08:13 AM
Authorized User
 
Join Date: Mar 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to myself.panku
Default GridView binding with Arraylist

Hi Guys,

I have bound gridview with an ArrayList and now i want to display the content of arraylist inside the TextBox using Template Column.
Like.

        ArrayList objArrFname = new ArrayList();
        objArrFname.Add("File 1");
        objArrFname.Add("File 2");

        GridView1.DataSource = objArrFname;
        GridView1.DataBind();

        ---------------------------------------

    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
        <Columns>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:TextBox ID="abcd" runat="server" Text=''></asp:TextBox>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>

---------------------------------------------------

I could have done it using RowDataBound event of GridView. But i do not want to move on Code-Behind file for Solution.

I just wanna confirm that what should i write in Text property of TextBox
                  <asp:TextBox ID="abcd" runat="server" Text=''></asp:TextBox>

If we were using DataTable/DataSet then we can write
Text = '<%# Eval("ColumnName") %>'

Thanks & Regards

Pankaj Bahuguna

__________________
Thanks
-Pankaj Bahuguna
 
Old November 5th, 2008, 03:19 AM
Registered User
 
Join Date: Oct 2008
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try like this for setting text

text = '<%# Container.DataItem %>'

Pankaj
www.dotnetspark.com
 
Old November 5th, 2008, 05:52 AM
Authorized User
 
Join Date: Mar 2008
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to myself.panku
Default

Thanks MAN...






Similar Threads
Thread Thread Starter Forum Replies Last Post
binding GridView at runtime! veda Visual Studio 2005 3 August 4th, 2008 06:44 AM
Binding GridView to ObjectDataSource which... rsearing ASP.NET 2.0 Professional 15 July 9th, 2008 01:44 AM
binding arraylist of structures to data grid in C# belzicool General .NET 1 May 9th, 2007 11:58 PM
Binding dropdownlist to gridView mcgarry101 ASP.NET 2.0 Basics 0 February 13th, 2007 07:12 AM
Binding fields on a gridview aldwinenriquez ASP.NET 2.0 Professional 0 June 1st, 2006 07:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.