Convert ASP.NET script to code behind

Discussion in 'ASP .Net' started by =?Utf-8?B?VGh1YmFpdGk=?=, Dec 25, 2004.

  1. Hi,

    I have this code in my ASP.NET and I want to convert it to C# (code behind)

    <asp:Repeater id="subCategoryRepeater" runat="server">
    <ItemTemplate>
    <ul>
    <li>
    <asp:HyperLink id="subCategoryHyperLink" runat="server" NavigateUrl='<%#
    "subcategory.aspx?subcategoryid=" +
    Convert.ToString(DataBinder.Eval(Container.DataItem, "id")) %>'>
    <%# Convert.ToString(DataBinder.Eval(Container.DataItem, "name")) %>
    </asp:HyperLink>
    </li>
    </ul>
    </ItemTemplate>
    </asp:Repeater>

    And this is my code behind:

    private void subCategoryName(SqlString categoryId) {
    subcat.CategoryId = categoryId.ToSqlDecimal();
    DataTable dataTable = subcat.SelectAllWcategoryIdLogic();

    subCategoryRepeater.DataSource = dataTable;
    subCategoryRepeater.DataBind();
    }


    Any help ?

    thanks
     
    =?Utf-8?B?VGh1YmFpdGk=?=, Dec 25, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?VGh1YmFpdGk=?=

    clintonG Guest

    Rename your old file as .txt and bring it into the project as an existing
    item.

    Load the .txt file in the IDE and use it as a reference.

    Load a new form, add the same type of controls to the new form that were
    used in the now renamed .txt file, modify the property names of the controls
    to match those in the .txt file and then copy reusable source from the .txt
    file into the new form where it is needed in the .aspx or the .cs
    code-behind.

    -- or --

    you have to write the declaration and signature for each control in the
    code-behind yourself.

    I think my suggested approach to rename and reuse is easier and fastest.


    --
    <%= Clinton Gallagher
    METROmilwaukee "Regional Information Services"
    NET csgallagher AT metromilwaukee.com
    URL http://clintongallagher.metromilwaukee.com/





    "Thubaiti" <> wrote in message
    news:...
    > Hi,
    >
    > I have this code in my ASP.NET and I want to convert it to C# (code

    behind)
    >
    > <asp:Repeater id="subCategoryRepeater" runat="server">
    > <ItemTemplate>
    > <ul>
    > <li>
    > <asp:HyperLink id="subCategoryHyperLink" runat="server" NavigateUrl='<%#
    > "subcategory.aspx?subcategoryid=" +
    > Convert.ToString(DataBinder.Eval(Container.DataItem, "id")) %>'>
    > <%# Convert.ToString(DataBinder.Eval(Container.DataItem, "name")) %>
    > </asp:HyperLink>
    > </li>
    > </ul>
    > </ItemTemplate>
    > </asp:Repeater>
    >
    > And this is my code behind:
    >
    > private void subCategoryName(SqlString categoryId) {
    > subcat.CategoryId = categoryId.ToSqlDecimal();
    > DataTable dataTable = subcat.SelectAllWcategoryIdLogic();
    >
    > subCategoryRepeater.DataSource = dataTable;
    > subCategoryRepeater.DataBind();
    > }
    >
    >
    > Any help ?
    >
    > thanks
     
    clintonG, Dec 25, 2004
    #2
    1. Advertising

  3. when I wrote this code, there is a compiler error about "Container" ?!

    Convert.ToString(DataBinder.Eval(Container.DataItem, "name"));


    Is there any way to convert "ONLY" this statement to code behind ??

    <%# Convert.ToString(DataBinder.Eval(Container.DataItem, "name")) %>



    Thanks...


    "clintonG" wrote:

    > Rename your old file as .txt and bring it into the project as an existing
    > item.
    >
    > Load the .txt file in the IDE and use it as a reference.
    >
    > Load a new form, add the same type of controls to the new form that were
    > used in the now renamed .txt file, modify the property names of the controls
    > to match those in the .txt file and then copy reusable source from the .txt
    > file into the new form where it is needed in the .aspx or the .cs
    > code-behind.
    >
    > -- or --
    >
    > you have to write the declaration and signature for each control in the
    > code-behind yourself.
    >
    > I think my suggested approach to rename and reuse is easier and fastest.
    >
    >
    > --
    > <%= Clinton Gallagher
    > METROmilwaukee "Regional Information Services"
    > NET csgallagher AT metromilwaukee.com
    > URL http://clintongallagher.metromilwaukee.com/
    >
    >
    >
    >
    >
    > "Thubaiti" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I have this code in my ASP.NET and I want to convert it to C# (code

    > behind)
    > >
    > > <asp:Repeater id="subCategoryRepeater" runat="server">
    > > <ItemTemplate>
    > > <ul>
    > > <li>
    > > <asp:HyperLink id="subCategoryHyperLink" runat="server" NavigateUrl='<%#
    > > "subcategory.aspx?subcategoryid=" +
    > > Convert.ToString(DataBinder.Eval(Container.DataItem, "id")) %>'>
    > > <%# Convert.ToString(DataBinder.Eval(Container.DataItem, "name")) %>
    > > </asp:HyperLink>
    > > </li>
    > > </ul>
    > > </ItemTemplate>
    > > </asp:Repeater>
    > >
    > > And this is my code behind:
    > >
    > > private void subCategoryName(SqlString categoryId) {
    > > subcat.CategoryId = categoryId.ToSqlDecimal();
    > > DataTable dataTable = subcat.SelectAllWcategoryIdLogic();
    > >
    > > subCategoryRepeater.DataSource = dataTable;
    > > subCategoryRepeater.DataBind();
    > > }
    > >
    > >
    > > Any help ?
    > >
    > > thanks

    >
    >
    >
     
    =?Utf-8?B?VGh1YmFpdGk=?=, Dec 25, 2004
    #3
  4. =?Utf-8?B?VGh1YmFpdGk=?=

    clintonG Guest

    Google: "Container.DataItem" produced [1],[2] which may help you understand
    what needs to be done.
    --
    <%= Clinton Gallagher
    METROmilwaukee "Regional Information Services"
    NET csgallagher AT metromilwaukee.com
    URL http://clintongallagher.metromilwaukee.com/

    [1] http://weblogs.asp.net/rajbk/archive/2004/07/20/188868.aspx
    [2]
    http://www.learnvisualstudio.net/vi...ng_DataBinder_Eval_and_Container_DataItem.htm

    "Thubaiti" <> wrote in message
    news:...
    > when I wrote this code, there is a compiler error about "Container" ?!
    >
    > Convert.ToString(DataBinder.Eval(Container.DataItem, "name"));
    >
    >
    > Is there any way to convert "ONLY" this statement to code behind ??
    >
    > <%# Convert.ToString(DataBinder.Eval(Container.DataItem, "name")) %>
    >
    >
    >
    > Thanks...
    >
    >
    > "clintonG" wrote:
    >
    > > Rename your old file as .txt and bring it into the project as an

    existing
    > > item.
    > >
    > > Load the .txt file in the IDE and use it as a reference.
    > >
    > > Load a new form, add the same type of controls to the new form that were
    > > used in the now renamed .txt file, modify the property names of the

    controls
    > > to match those in the .txt file and then copy reusable source from the

    ..txt
    > > file into the new form where it is needed in the .aspx or the .cs
    > > code-behind.
    > >
    > > -- or --
    > >
    > > you have to write the declaration and signature for each control in the
    > > code-behind yourself.
    > >
    > > I think my suggested approach to rename and reuse is easier and fastest.
    > >
    > >
    > > --
    > > <%= Clinton Gallagher
    > > METROmilwaukee "Regional Information Services"
    > > NET csgallagher AT metromilwaukee.com
    > > URL http://clintongallagher.metromilwaukee.com/
    > >
    > >
    > >
    > >
    > >
    > > "Thubaiti" <> wrote in message
    > > news:...
    > > > Hi,
    > > >
    > > > I have this code in my ASP.NET and I want to convert it to C# (code

    > > behind)
    > > >
    > > > <asp:Repeater id="subCategoryRepeater" runat="server">
    > > > <ItemTemplate>
    > > > <ul>
    > > > <li>
    > > > <asp:HyperLink id="subCategoryHyperLink" runat="server"

    NavigateUrl='<%#
    > > > "subcategory.aspx?subcategoryid=" +
    > > > Convert.ToString(DataBinder.Eval(Container.DataItem, "id")) %>'>
    > > > <%# Convert.ToString(DataBinder.Eval(Container.DataItem, "name")) %>
    > > > </asp:HyperLink>
    > > > </li>
    > > > </ul>
    > > > </ItemTemplate>
    > > > </asp:Repeater>
    > > >
    > > > And this is my code behind:
    > > >
    > > > private void subCategoryName(SqlString categoryId) {
    > > > subcat.CategoryId = categoryId.ToSqlDecimal();
    > > > DataTable dataTable = subcat.SelectAllWcategoryIdLogic();
    > > >
    > > > subCategoryRepeater.DataSource = dataTable;
    > > > subCategoryRepeater.DataBind();
    > > > }
    > > >
    > > >
    > > > Any help ?
    > > >
    > > > thanks

    > >
    > >
    > >
     
    clintonG, Dec 26, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nitc
    Replies:
    2
    Views:
    3,346
    Kevin Spencer
    Jun 26, 2003
  2. Ben Miller [msft]

    Re: Code Behind vs. no code behind: error

    Ben Miller [msft], Jun 27, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    606
    Alphonse Giambrone
    Jun 28, 2003
  3. Peri
    Replies:
    2
    Views:
    2,968
  4. keithb
    Replies:
    1
    Views:
    927
    Bruce Barker
    Mar 29, 2006
  5. John

    Non-code behind to code behind

    John, Feb 19, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    498
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Feb 19, 2007
Loading...

Share This Page