Home All Groups Group Topic Archive Search About
Author
20 Nov 2006 8:57 PM
Chuck P
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

Author
21 Nov 2006 3:15 AM
Walter Wang [MSFT]
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/managed/Default.aspx?dg=microsoft.publi
c.dotnet.framework.aspnet&mid=83fb8b7a-f96f-4384-919f-b74c8abb9b8c


Let me know if this answers your question. Thanks.

Sincerely,
Walter Wang (waw***@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
Author
21 Nov 2006 2:19 PM
Chuck P
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.



Show quoteHide quote
"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/managed/Default.aspx?dg=microsoft.publi
> c.dotnet.framework.aspnet&mid=83fb8b7a-f96f-4384-919f-b74c8abb9b8c
>
>
> Let me know if this answers your question. Thanks.
>
> Sincerely,
> Walter Wang (waw***@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
Author
22 Nov 2006 9:36 AM
Walter Wang [MSFT]
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 (waw***@online.microsoft.com, 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.