Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > GridView DDL and Label

Reply
Thread Tools

GridView DDL and Label

 
 
Chuck P
Guest
Posts: n/a
 
      11-20-2006
In my item template I have a label called ProductName
In my edit template I have a DDL called ProductName.

My object datasource for the gridview contains only the ProductID.

The DDL has an objectDatasource to Products table.

What is the best way that when I am in the normal view the label gets filled
with the ProductName.

Currently I have a function in the aspx page GetDescription(eval("ProductID"))

string GetDescription(string ID)
{
ienumerable inum= objectdatasource.select();
foreach item in inum
if inum.id ===id return inum.description;
}

Is their a better way to do this?
I toyed with putting something in the gridview's row event's


 
Reply With Quote
 
 
 
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      11-21-2006
Hi Chuck,

Based on my understanding, you're using a data-bound DropDownList in
EditTemplate of GridView and you want to know besides manually find the
current row's product name by code, is there any better way to do this?

Well, you could use data binding for the DropDownList and bind the
SelectedValue property to current row's field. Though you must turn on the
viewstate of this DropDownList to work correctly. See following thread:

http://msdn.microsoft.com/newsgroups...icrosoft.publi
c.dotnet.framework.aspnet&mid=83fb8b7a-f96f-4384-919f-b74c8abb9b8c


Let me know if this answers your question. Thanks.

Sincerely,
Walter Wang ((E-Mail Removed), remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
 
Chuck P
Guest
Posts: n/a
 
      11-21-2006
No that's a different issue. I would think mine has come up a lot but I
haven't seen ti discussed.

My issue is how to display a field that is not in the grid's data collection
when in the item template.



"Walter Wang [MSFT]" wrote:

> Hi Chuck,
>
> Based on my understanding, you're using a data-bound DropDownList in
> EditTemplate of GridView and you want to know besides manually find the
> current row's product name by code, is there any better way to do this?
>
> Well, you could use data binding for the DropDownList and bind the
> SelectedValue property to current row's field. Though you must turn on the
> viewstate of this DropDownList to work correctly. See following thread:
>
> http://msdn.microsoft.com/newsgroups...icrosoft.publi
> c.dotnet.framework.aspnet&mid=83fb8b7a-f96f-4384-919f-b74c8abb9b8c
>
>
> Let me know if this answers your question. Thanks.
>
> Sincerely,
> Walter Wang ((E-Mail Removed), remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications. If you are using Outlook Express, please make sure you clear the
> check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
> promptly.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscripti...t/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      11-22-2006
Hi Chuck,

Sorry for my misunderstanding.

I now understand your question is how to display the productname for label
in ItemTemplate. You already have a ObjectDataSource which will return all
products info and you only have productid in the data bound to the
GridView.

I don't think it's possible to use declarative way to bind the label to the
objectdatasource here since there're multiple row with different productid
and the row is already bound to the datasource of the GridView.

I think your solution works just fine, but you don't have to call
objectdatasource.select() every time. For each row, the binding are in the
same postback, you could use a member variable to cache the data from
objectdatasource and use it to find productname according to each row's
productid. This should improve performance.

Regards,
Walter Wang ((E-Mail Removed), remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


 
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
DDL fill and select value in gridview mik ASP .Net 1 05-12-2008 08:44 AM
GridView with DDL and selected value mik ASP .Net 2 05-11-2008 10:13 PM
GridView and DDL Mike Robbins ASP .Net Datagrid Control 2 03-15-2006 03:17 PM
Gridview - how get files in a dir for a ddl VB Programmer ASP .Net 2 02-09-2006 04:03 AM
Re: Persisting DDL.SelectedValue or DDL.SelectedItem.Value without Viewstate Marina ASP .Net 0 08-12-2003 07:08 PM



Advertisments