Re: #include for a DropDownList?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



THANKS THANKS THANKS!

"Steven Cheng[MSFT]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:tDmN6JiPHHA.2488@xxxxxxxxxxxxxxxxxxxxxxxxx
Thanks for your reply Joseph,

For your two questions:

1) Occassionally I have a list of delimited strings and would
like to get them into a C# page. This is usually for testing purposes as
I
need a quick source of data to test out some code. However, I can just as
well copy and paste it into the code.
========================================
If just for test purpose, another option would be define a utility class
which use some public methods(static or non-static) to return some list of
data items. And for any test page want to use those data, you can simply
drag a ObjectDataSource on the page and use ObjectDataSource to reference
that utility class. And those databound control like DropdownList,
GridView
... can directly use that objectdatasource to populate test data. How do
you think?

This worked fine. I had no idea that once I defined that ConstantUtil
class, it would show up as a DataSource. The first time I ever looked at an
ObjectDataSource its properties had an empty list for sources. I didnt know
that defining a class would populate that list.


2) For the global server url question, I think you can use a similar way
which can synchronize the value better. Define a public utility class
which
use static variables to hold the const url string. And in page template,
you can use server-side expression to render out the static const variable
to client script fragement. e.g.



=======util class=======
namespace TestNS
{
public class ConstantUtil
{
public
}

I had to put "static public string ServiceUrl" or the jscript below would
give an error. Leaving off static the C# still worked, but not the jscript.
Thanks again, I learned quite a byte today!

........
}

===============

=====aspx template========
<html xmlns="http://www.w3.org/1999/xhtml"; >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
var url = '<%= TestNS.ConstantUtil.ServiceUrl %>';
</script>
.......



.



Relevant Pages

  • Gridview Update via ObjectDataSource Issue
    ... I have a GridView populated by an ObjectDataSource. ... I am having issues passing the parameters to the objectdatasource. ... strSer As String, ByVal strPO As String, ByVal strPrj As String, ByVal ... populate my Update method? ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: #include for a DropDownList?
    ... Occassionally I have a list of delimited strings and would ... another option would be define a utility class ... drag a ObjectDataSource on the page and use ObjectDataSource to reference ... use static variables to hold the const url string. ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Sorting objects, that are in an ArrayList?
    ... I'm consuming this ArrayList from an ObjectDataSource and would like to have this support sorting. ... I can't simply sort the ArrayList. ... {string FirstName; ...
    (microsoft.public.dotnet.languages.csharp)
  • Checkboxes in FormView bound to ObjectDataSource
    ... I have a formview bounded to an objectdatasource. ... The field bounded in the database is a string field ... protected string _login; ... public string Login ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: ObjectDataSource Parameters Adding
    ... the parameter value must always be a string. ... When creating the ObjectDataSource it recognized that an Int32 argument was needed. ... I tried odsRFranOrder.SelectParameters.Add("OrderID", System.TypeCode.Int32, orderid); where orderid is an int32 but I get an error saying that my argument should be a string!! ...
    (microsoft.public.dotnet.framework.aspnet)