DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Store Data Into Dropdownlist Inside GridView EditItemTemplate And FooterTemplate

  1. #1
    Join Date
    Oct 2009
    Location
    I rasied in Philippines and residing for the meantime as for work here in Gulf countries
    Posts
    1

    Angry Store Data Into Dropdownlist Inside GridView EditItemTemplate And FooterTemplate

    Is Anyone Encountered Error as Message Like This ==> ASP.NET Using CSharp Visual Studio 2008

    "NullReferenceException was unhandled by user code"

    Where I just want to Bind DropdownList that declared inside GridView?
    Here where I Construct GridView
    =======================================================
    <asp:GridView ID="GridOne" runat="server" OnRowDataBound="dvg_RowDatabound" AutoGeneratedColumns="Fales">
    <Columns>
    <asp:TemplateField HeaderText="Code">
    <EditItemTemplate>
    <aspropDownList ID="DDL" runat="server" ></aspropDownList>
    </EditItemTemplate>
    </asp:TemplateField>
    </Columns>
    </asp:GridView>

    ================== The Code Behind =====================
    protected void dvg_RowDatabound(object sender, GridViewRowEventArgs e)
    {

    if (e.Row.RowType == DataControlRowType.DataRow)
    {

    DataTable Dtb = Ds.Table[0];

    DropDownList DDl1 = (DropDownList) e.Row.FindControl("DDl") as
    DropDownList;


    DDl1.DataSource=Dtb; << = Error Start Here as Above Error
    Appear Message

    DDl1.DataMember = "MyDataMember"
    DDl1.DataValueField = "MyValue"
    DDl1.DataBind();

    }


    }
    =====================================================

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    Do you know what line is causing the error?

Similar Threads

  1. Replies: 6
    Last Post: 06-12-2008, 08:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center