Is there a WPF RowDetails functionality for ASP.NET? - 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>

Related

Change value of custom table data in a repeater

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.

ASP.Net Repeater from Entity Framework (Webform Markup)

I'm having problem finding information on selecting data from an Entity Framework entity from within the markup of an ASP.Net Repeater
I have a Repeater like this:
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="s_Options">
<HeaderTemplate>
<table>
<tr>
<th>Manager Name</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><% !!!!! MY PROBLEM IS HERE %></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
And I have an Entity called Option.
Option has 3 members:OID, Option_Type, and Option_Value
I am trying to populate this repeaters with Option_Values where Option_Type = "This Option" but I am completely lost on how to do this in the item template and I am having trouble wording my question correctly to find answers to it elsewhere.
First of all, if doing this in the markup for the Repeater is not the best way, please let me know.
Additionally, I am looking for any help on how to filter this entity and how the markup looks.
Also, if this is something that has been covered somewhere else, then I apologize, I must be asking the question incorrectly. If you could help me articulate what I'm asking in a more constructive way, please let me know.
If I understand you question correctly, you want -
<ItemTemplate>
<td><%# Eval("Option_Type") %></td>
</ItemTemplate>
Take a look at the bottom of Displaying Data with the DataList and Repeater Controls article.
Use this code and put your table column name in Eval..
<table style="width: 400px">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<tr>
<td>
<asp:Label ID="LBLtEXT" runat="server" Text='<%#Eval("Your filed name ")%>'></asp:Label>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>

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>

FindControl() Keeps Returning Null!

I realise there are many posts on the web about this already but I cant seem to find any for my particular problem!
I have a dynamic table that is populated using a repeater.
the code is:
<asp:Repeater ID="rptPending" runat="server">
<HeaderTemplate>
<table id="tblPending" cellpadding="0" cellspacing="0" border="0" class="display">
<thead>
<tr>
<th>Company Name</th>
<th>Telephone</th>
<th>Fax Number</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td runat="server">
<asp:TextBox ID="a" runat="server" TextMode="MultiLine" Rows="1"
onChange="__doPostBack($(this).attr('name'),$(this).parent().attr('id'));"
Text='<%# Eval("_companyName")%>'></asp:TextBox>
</td>
<td runat="server">
<asp:TextBox ID="b" runat="server" TextMode="MultiLine" Rows="1"
onChange="__doPostBack($(this).attr('name'),$(this).parent().attr('id'));"
Text='<%# Eval("_telephone")%>'></asp:TextBox>
</td>
<td runat="server">
<asp:TextBox ID="c" runat="server" TextMode="MultiLine" Rows="1"
onChange="__doPostBack($(this).attr('name'),$(this).parent().attr('id'));"
Text='<%# Eval("_faxNo")%>'></asp:TextBox>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody> </table>
</FooterTemplate>
</asp:Repeater>
Once this table has been populated with data from a datasource, a jquery script iterates through every table cell and edits the id's accordingly. cell_0_0, cell_0_1, cell_0_2 etc.
Now When the text on these text areas change, a postback is initiated, with the __EVENTTARGET being the textarea ID, and the __EVENTARGUMENT being the table cell (parent) ID.
These get sent to the server-side no problem. The issue I am having is GETTING THE TEXT inside the text area...
I have tried adding controls using FindControl("cell_0_0"); Which returns null. Then i found out the FindControl() function IS NOT recursive, so i copied a recursive function off the net... and it Still Fails!
Basically ALL i need to do is GET the value (either innerText or InnerHTML). Ive tried using Control, HtmlControl, HtmlTableRow, and HtmlTextArea.
I just cant seem to get the value. Ive tried recursing throught i a noted earlier, but the controls arent even registered. Im confused.
PLEASE HELP!
Thanks
Alex
Well this is a usually issue, because of the timing of the creations of the controls, and when you create control inside a repeater the timing is even more complex because repeater must first full bind, and then search for the controls.
In my programs to avoid all that I just get the posted value from the Form and I actually not first search to find the control. So just get your posted values from the Request.Form and move on.
Request.Form
All the post data lives on Request.Form, so you can simple get the one you need, or find the one you need. Just a note, to get a value using the Form use the UniqueID, and not the ClientID. Even better get the value from your custom name ids.

ASP.NET User control with ASP:CreateUserWizard

When using asp:login, asp:forgotpassword and asp:createuserwizard controls within an ascx. (e.g registration.ascx) it can't find e.g UserName, even though it exists within LayoutTemplate. Any idea how to fix this?
If you open smart tag for control in design mode,you shall see that there are steps that can be convertible to templates for customization.
CreateUserWizard http://img197.imageshack.us/img197/3823/7d4df5a594a1abdb8fdc8f1.png
For CreateUserWizard , press Customize Create User Step and you will observe that,control is converted into a table template which you can see how controls named i.e. UserName,Password...
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
<WizardSteps>
<asp:CreateUserWizardStep runat="server" ID="CreateUserWizardStep1">
<ContentTemplate>
<table border="0">
<tr>
<td align="center" colspan="2">
Sign Up for Your New Account</td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
.......
Also know that If you wish to find control from inner templates , you must look for templates with FindControl method to reach the control you desire.
To Find UserName Control in above code,use
CreateUserWizardStep1.TemplateControl.FindControl("UserName") as TextBox
Hope this helps to solve your problem

Resources