GridView not displayed

Last post 01-08-2008 12:56 PM by mosessaur. 1 replies.

Sort Posts:

  • GridView not displayed

    01-08-2008, 12:34 PM
    • Loading...
    • bendJoe
    • Joined on 08-31-2007, 4:31 PM
    • Posts 374

    Hello, 

    I have a simple test GridView it is not showing up. The code is shown below. 

    HelpDeskTableAdapters.USER_DETAILSTableAdapter adapter = new HelpDeskTableAdapters.USER_DETAILSTableAdapter();
        HelpDesk.USER_DETAILSDataTable userTable;
    
        ArrayList alist=new ArrayList ();
        protected void Page_Load(object sender, EventArgs e)
        {
            userTable = adapter.GetUserData();
            foreach (HelpDesk.USER_DETAILSRow userrow  in userTable)
            {
                alist.Add(userrow.WORK_EMAIL);
            }
            GridView2.DataSource = alist;
            GridView2.DataBind();
            
        }

      <asp:GridView ID="GridView2" runat="server" Style="z-index: 102; left: 432px; position: absolute;
                top: 376px">
            </asp:GridView>

     

    What is wrong here?

    Thanks. 

  • Re: GridView not displayed

    01-08-2008, 12:56 PM
    Answer
    • Loading...
    • mosessaur
    • Joined on 07-11-2002, 2:40 PM
    • Cairo
    • Posts 352

    you are binding an ArrayList to the GridView, your ArrayList contains object with no properties, looks like simple string. When binding ArrayList to GridView, the objects stored inside the list should have properties to be used as fields on GridView for binding.

    So just try to set your data table as data source to your GridView without using ArrayList.

    checkout this post

    http://forums.asp.net/t/948712.aspx 

    Muhammad M. Mosa Soliman
    Software Engineer
    Moses's Blog
Page 1 of 1 (2 items)
Microsoft Communities
Page view counter