Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > dropdown list in gridview does not seem to display correct data

Reply
Thread Tools

dropdown list in gridview does not seem to display correct data

 
 
Paul
Guest
Posts: n/a
 
      07-02-2008
I have a gridview and in the RowDataBound I have the line of code below. I
have the ObjDtaSce= to the datasource of a dropdown box. I have 3 rows that
are populated and for some reason the dropdown box for all rows is populated
by values expected in the last row only. I checked the ID value and it is
correct for each row. Is there something I would need to reset?

protected void gridview_RowDataBound(object sender, GridViewRowEventArgs e)
'''
'''

ObjDtaSce.SelectParameters["ID"].DefaultValue =Convert.ToString
(integervariable);//
thanks.

--
Paul G
Software engineer.
 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      07-03-2008
You seem to be databinding declaratively with DataSourceID property. In this
case actual select operation takes place in the PreRender event which fires
well after all your RowDataBound events. You need to databind in the
RowDataBound event itself. Simply databind with the DataSource property
instead of DataSourceID and call myDdl.DataBind() method.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


"Paul" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a gridview and in the RowDataBound I have the line of code below. I
> have the ObjDtaSce= to the datasource of a dropdown box. I have 3 rows
> that
> are populated and for some reason the dropdown box for all rows is
> populated
> by values expected in the last row only. I checked the ID value and it is
> correct for each row. Is there something I would need to reset?
>
> protected void gridview_RowDataBound(object sender, GridViewRowEventArgs
> e)
> '''
> '''
>
> ObjDtaSce.SelectParameters["ID"].DefaultValue =Convert.ToString
> (integervariable);//
> thanks.
>
> --
> Paul G
> Software engineer.



 
Reply With Quote
 
 
 
 
Paul
Guest
Posts: n/a
 
      07-03-2008
Thanks that worked! I removed the datasourceID that was set in the
properties box and then just set the datasource and executed a databind as
shown below.

(e.Row.Cells[2].FindControl("dropdown2") as DropDownList).DataSource =
ObjDtaSce;
(e.Row.Cells[2].FindControl("dropdown2") as DropDownList).DataBind();
--
Paul G
Software engineer.


"Eliyahu Goldin" wrote:

> You seem to be databinding declaratively with DataSourceID property. In this
> case actual select operation takes place in the PreRender event which fires
> well after all your RowDataBound events. You need to databind in the
> RowDataBound event itself. Simply databind with the DataSource property
> instead of DataSourceID and call myDdl.DataBind() method.
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
> http://usableasp.net
>
>
> "Paul" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I have a gridview and in the RowDataBound I have the line of code below. I
> > have the ObjDtaSce= to the datasource of a dropdown box. I have 3 rows
> > that
> > are populated and for some reason the dropdown box for all rows is
> > populated
> > by values expected in the last row only. I checked the ID value and it is
> > correct for each row. Is there something I would need to reset?
> >
> > protected void gridview_RowDataBound(object sender, GridViewRowEventArgs
> > e)
> > '''
> > '''
> >
> > ObjDtaSce.SelectParameters["ID"].DefaultValue =Convert.ToString
> > (integervariable);//
> > thanks.
> >
> > --
> > Paul G
> > Software engineer.

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
1 Gridview. Dropdown A is column from database, Dropdown B is column from database, Data in A and B must be from same row. anonymoushamster@gmail.com ASP .Net 2 11-07-2007 12:40 PM
<location> element does not seem to work - Does anybody know how to solve this. alexvodovoz@yahoo.com ASP .Net 1 05-25-2007 01:12 AM
Does list.clear() delete the objects in the list? If not, what is the correct method? Michael Jasn C++ 1 11-01-2004 10:06 AM
Webservice works once and then DOES NOT seem to work even though program does not crash Phi! ASP .Net Web Services 1 04-23-2004 08:42 AM
correct or not correct? Dan HTML 7 10-02-2003 10:16 PM



Advertisments