Re: Null reference in Item

Tech-Archive recommends: Speed Up your PC by fixing your registry



Avnrao,

Other thing I notice that the data seems to bind to the dropdownlist when I
click on the edit link of the datagrid row. Do you have any idea what might
cause it?

Sam



"avnrao" <avnrao@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3CE16162-CC51-49B9-A531-5EF8914C4D6E@xxxxxxxxxxxxxxxx
I think you need to use this check

if ( e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem )
{
//bind data
}

Note : code is in C#.

"Sam" wrote:

Hi All,

I'm having troubles with populating data to the dropdownlist in a
datagrid
and I just don't know what causes it. I have been struggling for 2 days
now
Would some one give me a hand?

Here is what I have in the ItemDataBound

Dim ddlProduct As DropDownList =
CType(e.Item.Cells(1).FindControl("ddlFinalOffer"),
System.Web.UI.WebControls.DropDownList)

Dim ds1 As DataSet

ds1 = CreateDataSet()

ddlProduct .DataTextField = "ProductDesc"

ddlProduct.DataValueField = "ProductID"

ddlProduct .DataSource = ds1.Tables(0)

ddlProduct.DataBind()





some how I keep having null reference error and when I debug it, the
ddlProduct variable shows "nothing" when I hover my mouse on this
variable.
It breaks when I tried to assign datafield to it. The code above shows
ok
if I put in the "edit" event handler of the datagrid but the data does
not
get populated in the dropdownlist.

Regards,

Sam





.



Relevant Pages

  • Null reference in Item
    ... I'm having troubles with populating data to the dropdownlist in a datagrid ... Dim ddlProduct As DropDownList = ... ddlProduct .DataTextField = "ProductDesc" ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Drop Down List inside a Datagrid
    ... Charlie ... I have an EditItemTemplate inside a datagrid. ... > show possible choices when the user clicks the edit link. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Drop Down List inside a Datagrid
    ... I have an EditItemTemplate inside a datagrid. ... I have an EditCommandColumn. ... possible choices when the user clicks the edit link. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Datagrid dynamic button focus
    ... I have a datagrid of categories that uses the EditCommandColumn to do ... When the Add button is called I refocus both ... But right now, when a user hits the edit link, the ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Edit on Datagrid causes the page to jump on the screen
    ... Finland, EU ... > Everytime I try to edit a row on my datagrid, I press on the edit Link ...
    (microsoft.public.dotnet.framework.aspnet)