Change value of custom table data in a repeater - asp.net

I want to create a page where the user can modify my custom table data. I currently have a Custom table data source and a Basic repeater. The Transformation looks like this:
<table border="1" style="border-collapse: collapse" width="200">
<tr>
<th>Node ID:</th>
<td><%# Eval("helpful_nodeID") %></td>
</tr>
<tr>
<th>Culture Code:</th>
<td><%# Eval("helpful_cultureCode") %></td>
</tr>
<tr>
<th>Not Helpful:</th>
<td><%# Eval("helpful_no") %></td>
</tr>
<tr>
<th>Helpful:</th>
<td><%# Eval("helpful_yes") %></td>
</tr>
<tr>
<button>Clear rating</button>
</tr>
</table>
So I would like my button to have the opposite effect of Eval, and force the value of 0 for "helpful_no" and "helpful_yes".
Is there an easy way, such as <% Set ("helpful_yes") = 0 %> for example?

Unfortunately, there is no such easy thing as an Set method which would store the data. Neither in ASP.NET nor in Kentico. The best way is probably creating your own user control/ webpart to do it.
EDIT:
Following materials may be useful.
How to create new webpart
Every installation of Kentico also contains API examples section. If you are on Kentico 8, just open application list, type API examples, open it. There under development section you'll find custom tables examples which shows how to do basic manipulation with custom table objects.

Related

Can you use a classic asp table in asp.net?

I am unsure if you can still use a table in asp.net and have the fields filled in via a dataset.
This was done in the old asp.
<table border="0" cellpadding="0" cellspacing="0" id="Table1">
<tr>
<td class="test1"><strong>Person Number:</strong></td>
<td class="test2"><%=DataSetvalue("PNum")%></td>
</tr>
<tr>
Yes! you can do it.
Have a look on following links
http://www.shiningstar.net/blog/tables.aspx
http://www.w3schools.com/aspnet/control_table.asp

Editable fields in Spring MVC

I'm a newbie to Spring MVC. Here's my question.
I have a input view where a user can input a name and a text, which will then be displayed like this:
<tr>
<td>Name: </td>
<td>${product.name}</td>
</tr>
<tr>
<td>Text: </td>
<td>${product.text}</td>
</tr>
How can I make the two fields editable for the user? I'd like to place a link or so next to each field, that the user can use for editing entries.
Furthmore, I'd like to link the request to the same page as the input page/form, how can I distinguish the two cases in my controller? I'm using SimpleFormController...
You can use a <a href tag as follows:
${product.text}
Therefore, in your example above, you could use the following:
<tr>
<td>Name: </td>
<td>${product.name}</td>
</tr>
<tr>
<td>Text: </td>
<td>${product.text}</td>
</tr>
Your edit page link urls will have to be the correct link to that edit page.
Alternative:
However, another way to make the fields editable is to use the spring <form> tags as below:
<form:input path="name" placeholder="${product.name}" />
<form:input path="text" placeholder="${product.text}" />

Load data into a UserControl as control properties or in control code behind?

I'm building a UserControl that will repeat on the page a variable number of times. I'm trying to determine what the most efficient way to handle the data I will be loading into the Control. For the sake of simplicity, lets say it will be structured something like this:
<table>
<tr>
<td>Header Item</td>
</tr>
<tr>
<td>Body Item n</td>
</tr>
<tr>
<td>Body Item n+1</td>
</tr>
<tr>
<td>Body Item n+2</td>
</tr>
<tr>
<td>etc.</td>
</tr>
<tr>
<td>Footer Item</td>
</tr>
</table>
All of the data that will be loaded into this Control will come from a SQL Query. The Body items will be changing on every iteration of the control, but the Header and Footer items will be the same, and that is where I am trying to decide between a couple of options I can see.
Build the query into the code behind of the control itself and repeat it for every iteration of the control, or:
Query the data from the .aspx.cs page where the control will be used and deliver them as properties when the control is created.
?
Option 1 seems very inefficient. If we were talking about only two items, then I might just be inclined to accept the inefficiency, but we're talking about a lot more.
Option 2 seems plausible, but I have no idea if that is actually any better than option 1.
Thoughts? Other options?
Use a Repeater control
Have a look here:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater(v=vs.80).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
<asp:Repeater runat="server">
<HeaderTemplate>
<table>
<tr>
<td>Header Item</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>Body Item <%# Eval("Number") %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>Footer Item</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>

How to add rows to a table dynamically with asp.net

I want to generate a table in following fashion :
<table>
<tbody>
<tr class="folder" style="-moz-user-select: none;">
<td><div><img src="folder.png"><span>home</span></div></td>
<td class="bytes">Folder</td>
</tr>
<tr class="folder hover" style="-moz-user-select: none;">
<td><div><img src="folder.png"><span>share</span></div></td>
<td class="bytes">Folder</td>
</tr>
</tbody>
</table>​
I want to add the rows from the CS code depending on the number of entries.
Instead of "adding elements to html table" you should consider using Repeater for data display, which would give you clean html (exactly as you want).
Then on each click you would do what you need to do (code behind) and rebind the repeater.
Hope that helps.
I would agree with Sebastian why not use a repeater or datalist to bind the data. What source are you using to get your data from? If your pulling the data from a SQL table here is a pretty good article on how to get you started.
http://msdn.microsoft.com/en-us/library/aa719636(v=vs.71).aspx

Is there a WPF RowDetails functionality for ASP.NET?

Im getting started with ASP.NET. I need to let users click on rows of a table and then show them some extra information relating to that row. This is down using RowDetails templates in WPF. I am wondering is there anything similar for ASP.NET?
I would use a Repeater with a Table, and make it so each RepeaterItem is two table rows. Make the 2nd row hidden, and the 1st row toggle the 2nd one's visibility when clicked on.
I don't remember the exact syntax, but it looks something like this:
<asp:Repeater>
<HeaderTemplate><table></HeaderTemplate>
<ItemTemplate>
<tr click="javascript: ToggleNextRow(this);">
<td><%# Eval("Id") %></td>
<td><%# Eval("Name") %></td>
<td><%# Eval("Description") %></td>
</tr>
<tr style="display: none;">
<td colspan="3"><%# Eval("Details") %></td>
</tr>
</ItemTemplate>
<FooterTemplate></table></FooterTemplate>
</asp:Repeater>

Resources