Convert ASP.NET script to code behind

G

Guest

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
 
C

clintonG

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.
 
G

Guest

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...
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top