Convert ASP.NET script to code behind

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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.
 
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...
 
Back
Top