Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

find dropdownlist inside gridview and fill list

Posted on 2011-02-10
4
Medium Priority
?
333 Views
Last Modified: 2012-05-11
     
is this correct?    i am getting this error
Error=Object reference not set to an instance of an object., Timestamp=2/10/2011 3:33:46 PM

Dim itemWhse As New System.Web.UI.WebControls.DropDownList
            itemWhse = CType(e.Item.Cells(9).FindControl("lstWhse"), System.Web.UI.WebControls.DropDownList)
                    itemWhse.Items.Add(New ListItem("GA", "GA"))
                itemWhse.Items.Add(New ListItem("MO", "MO"))
                itemWhse.Items.Add(New ListItem("NY", "NY"))
                itemWhse.Items.Add(New ListItem("OR", "OR"))
                itemWhse.Items.Add(New ListItem("SALE", "SALE"))
                itemWhse.Items.Add(New ListItem("123", "123"))
0
Comment
Question by:Wigging
  • 3
4 Comments
 
LVL 61

Expert Comment

by:HainKurt
ID: 34866003
try DirectCast

itemWhse = DirectCast(e.Item.Cells(9).FindControl("lstWhse"), System.Web.UI.WebControls.DropDownList)

and make sure the control you are looking for inside that cell, remember index start with 0 (try 8 or 10)
0
 
LVL 61

Accepted Solution

by:
HainKurt earned 2000 total points
ID: 34866009
also try

itemWhse = DirectCast(e.Item.FindControl("lstWhse"), System.Web.UI.WebControls.DropDownList)
0
 

Author Comment

by:Wigging
ID: 34866072
also if the item is supposed to show on edit
in which even should i add this code?

item created   or datagrid1EditCommand  or datagrid1ItemDataBound
0
 
LVL 61

Expert Comment

by:HainKurt
ID: 34866521
DataGrid.EditCommand Event

Occurs when the Edit button is clicked for an item in the DataGrid control.

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.editcommand.aspx
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question