sorry in advance I have searched the whole site but I can not find an answer to this question
I plan to use the listview with checkboxes in every item and one delete button so that I can do a removal to multiple row at once, is there any way that I can start this work?
this is my current code
<asp:ListView ID="ListInbox" runat="server" DataKeyNames="MessageID"
DataSourceID="LinqDataSourceInbox" >
<EmptyDataTemplate>
There is no message
</EmptyDataTemplate>
<ItemTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<asp:CheckBox ID="CheckBoxSelect" runat="server" />
</td>
<td runat="server">
<asp:Panel ID="PanelMsg" runat="server" Width="400px">
<a href='UserProfile.aspx?UserName=<%# Eval("FromUserName") %>'><img src="ProfilePic/<%#Eval("User.ProfilePic") %>" alt='' width="25" /></a>
<a href='UserProfile.aspx?UserName=<%# Eval("FromUserName") %>'><%# Eval("FromUserName") %></a>
write you message:
<a href='ViewMessages.aspx?MsgID=<%# Eval("MessageID") %>'><%# Eval("Subject") %></a>
<%# Eval("MessageTime") %>
</asp:Panel>
</td>
</tr>
</table>
<hr style="text-align:left; width:400px;" />
</ItemTemplate>
<LayoutTemplate>
<div style="min-height:450px;">
<div runat="server" id="itemPlaceholder">
</div>
</div>
</LayoutTemplate>
</asp:ListView>
The questions are
Where the CheckBox put? Selected/Item template?
Where the Delete Button put? Inside/Outside ListView?
Thx in advance..
We do smth similar with a GridView backed with a DataTable, I suppose I can give you a general idea and you can do smth similar.
Create a flag column/ field. e.g: User.SetToDelete
onCheckChanged set this flag to true.
Upon Click of the delete button, iterate the rows and look for items set to be deleted.
As for the suggestion for a simple GUI:
Hope it helps.
Related
In my asp.net application there are several dropdown and textbox control which creates dynamically. So on select of dropdown while data is being fetched I want to show update progress on div. Also I dont want to post back call so whole page should not be refreshed.
Here is my code
<div class="col-md-2">
<div class="filter-section">
<table>
<tr>
<td>
<asp:Panel ID="ControlsParent" ViewStateMode="Enabled" ClientIDMode="Static" runat="server"></asp:Panel>
</td>
</tr>
<tr>
<td>
<asp:Button ID="BtnShowReport" runat="server" ClientIDMode="Static" CssClass="btn btn-primary btn-block" Text="Show Report" OnClick="BtnShowReport_Click" />
</td>
</tr>
</table>
</div>
</div>
I am new to Telerik so dont have idea to use.
Put the code insiode the Update Panel, I am using Simple asp and haven't used Telerik in following:
// you code codes here
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress DynamicLayout="true" ID="upProgSearch" DisplayAfter="1500" runat="server" >
<ProgressTemplate>
<div id="progressBackgroundFilter"></div>
<div id="processMessage" style="width:100px;">
<asp:Image ID="Image1" ImageUrl="~/images/Loading.gif" runat="server" />
</div>
</ProgressTemplate>
</asp:UpdateProgress>
for preventng auto postback use <triggers> tags in update panel and use <asp:AsyncPostBackTrigger> and specify the event name that causes postback and you don't want .
I have a very small search functionality and I have a table row called "Search Results", I want this table row get displayed whenever i have something to display from the search results. So I want to hide this row by default and enable via code behind when my search is fetching some result.
<div>
<table>
<tr id="srchResultHeader" style="display: none;" class="header">
<td colspan="2" class="tdlogintitle" visible="false">Search Results</td>
</tr>
<tr>
<td>/*Data to display actual result from database*/</td>
</tr>
</table>
</div>
I'm not able to get the reference of the above table id "srchResultHeader" in my code behind? What is wrong here in my code.
An id by itself is just a client-side identifier. In order for this to be referenced as a server-side object it needs to be a server-side control. The easiest way would just be to add runat="server" on the existing element:
<tr runat="server" id="srchResultHeader" style="display: none;" class="header" >
In this case you probably don't even need the style attribute, since you're controlling the hide/show functionality in server-side code. You can just set .Visible on the control to determine whether or not it renders to the client-side markup at all.
You could use server-side <asp:Table> for this very purpose. Otherwise <tr> is a client-side thing and is not directly accessible in the server-side code. <asp:Table> will render <table> tag on the client-side, but you can access it in the code-behind through its ID. The structure looks like this:
<asp:Table ID="MyTable" runat="server">
<asp:TableRow runat="server" ID="MyRow1">
<asp:TableCell>Some value</asp:TableCell>
</asp:TableRow>
</asp:Table>
You can now write something like this in the code-behind:
MyRow1.Visible = False;
.aspx
<tr id="divDriverName1" runat="server" >
<td >
<label class=" ">label1 </label>
<asp:TextBox ID="TextBox1" runat="server" class=" form-control"></asp:TextBox>
</td>
</tr>
.aspx.cs
ContentPlaceHolder myPlaceHolder = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
HtmlTableRow ct = (myPlaceHolder.FindControl("divDriverName1")) as HtmlTableRow;
divDriverName1.Attributes.Add("style", "display:none");
<div class="row" id="divhiddenInfo2" runat="server" style="display: none">
</div>
Hi i have a 3 tiered nested repeater and i need to access the values in the repeater condRptr below on postback, i tried everything but dont seem to be able to get anywhere. I had the table originally within the repeater with runat server in the header template but this threw an error.
Anyone got any ideas??
<asp:Repeater ID="deptRepeater" runat="server" OnItemDataBound="bindDepts">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<div id="itemContainer">
<h3 class="fdAccordionHeader"><%# Eval("desc") %><span class="fdAccordionHeaderIcon"></span></h3><asp:HiddenField ID="deptid" runat="server" Value='<%# Eval("dept_id") %>' />
<div class="fdAccordionContent" style="display:none">
<asp:Repeater ID="prodRepeater" runat="server" OnItemCommand="itemToCart">
<HeaderTemplate>
</HeaderTemplate>
<ItemTemplate>
<div>
<h4 class="fdProductHeader"><span class="fdProductHeaderTitle"><%# Eval("desc") %></span><span class="fdProductFeatured"></span><span class="fdProductHeaderPrice">€<%# Eval("price") %></span><span class="fdClearBoth"></span></h4>
<div class="fdProductContent" style="display:none">
<img class="fdProductImage" src="http://wingit.ie/script/app/web/img/frontend/noimg.png" alt="">
<div class="fdProductContentRight">
<div class="fdProductDesc">A helping of our delicious wings, served with fries and a drink of your choice. Perfect if you're particularly hungry!</div>
<input type="hidden" name="product_id" value="2">
<!---->
<asp:LinkButton ID="btnOrder" runat="server" CssClass="fdButton fdButtonOrder" CommandName="addToCart" CommandArgument='<%# Eval("product") %>' ></asp:LinkButton>
<table id="condimentsContainer" cellpadding="0" cellspacing="0" runat="server">
<asp:Repeater ID="condRptr" runat="server">
<ItemTemplate>
<tr><td>
<table id='condiments' cellpadding="0" cellspacing="0" class="fdProductExtraTbl" runat="server">
<tbody>
<tr>
<td><%# Eval("pDesc") %></td>
<td class="fdProductExtraTblPrice"><asp:Label ID="priceLvl" runat="server">€<%# Eval("pPrice") %> x</asp:Label>
<input id="modifier" class="modifier" type="text" name="extra_id[3]" value="0" runat="server"/>
<input id="hdProd" type="hidden" value='<%# Eval("pCode") %>' runat="server"/>
</td>
<td class="fdProductExtraTblIco"></td>
<td class="fdProductExtraTblIco"></td>
</tr>
</tbody>
</table>
</td></tr>
</ItemTemplate>
</asp:Repeater>
</table>
</div>
<span class="fdClearLeft"></span>
</div>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
</div>
</div>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:Repeater>
Ok so as no-one had any ideas ;) i eventually figured out a nifty work around for this, because i couldn't have the runat server in the header template, i basically put it in the
element like so
<tr ID="dataRow" runat="server"> rest of data </tr>
Then in the C# code on the server side i was able to use the RepeatEreventArgs and cast the as a HtmlTableRow so that i could iterate through the data - simples :)
I am currently fighting against a Listview, I'm trying to have two images (with headlines on etc.) beside each other, but I can't figure it out.
My code looks like this:
<asp:ListView runat="server" ID="LWArticleList">
<ItemTemplate>
<table id="TableArticleList" class="repclass">
<tr>
<td>
<div class="thumb main">
<p class="thumb-comment">
<asp:HyperLink ID="CommentHyperLink" runat="server" CssClass="comment-count">10</asp:HyperLink></p>
<asp:HyperLink ID="ArticleLink" runat="server" NavigateUrl='<%# string.Format("~/Article.aspx?id={0}", Eval("ID")) %>'>
<asp:Image ID="Image1" Width="250px" Height="170px" runat="server" ImageUrl='<%# string.Format("{0}/{1}", ImageService.ImageLocation, Eval("Image")) %>' />
</asp:HyperLink>
<div class="thumb-title">
<h2><asp:HyperLink ID="LinkTitle" runat="server" Text='<%# Eval("Headline") %>' /></h2>
<p><asp:Literal ID="LitSummary" runat="server" Text='<%# Eval("Summary") %>' /></p>
</div>
</div>
</td>
</tr>
</table>
</ItemTemplate>
</asp:ListView>
I wish my content to be shown like this:
Article 1 | Article 2
Article 3 | Article 4
But at the moment mine looks like this:
Article 1
Article 2
Article 3
Article 4
How can I change this?
It could be because you only have one table cell <td> so this will only ever be a 1 column listview.
For example, to display a two-column table, you would render three table cells (<td>) in each table row (<tr>), like so:
<table ...>
<tr>
<td>Article 1</td>
<td>Article 2</td>
</tr>
...
<tr>
<td>Article N - 1</td>
<td>Article N</td>
</tr>
</table>
You are displaying your data in a table for each item in your data source. You should rethink that approach.
Tables' display property is block by default, so this is why your items display as they do.
I'm using a Repeater:
<form id="form1" runat="server">
<div>
<asp:Repeater ID="repeater" runat="server" OnItemDataBound="repeater_ItemDataBound">
<ItemTemplate>
<tr>
<td>
<asp:CheckBox ID="checkbox" runat="server" AutoPostBack="false" OnCheckedChanged="Check_Clicked" data-id='<%# DataBinder.Eval(Container.DataItem, "ProfileID") %>'
Text="I agree" />
</td>
<td>
<asp:Label ID="lblProfileDesc" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ProfileDesc") %>'></asp:Label>
</td>
</tr>
<br />
</ItemTemplate>
</asp:Repeater>
<asp:Button ID="btn" runat="server" Text="Click" onclick="btn_Click" />
</div>
</form>
I'm handling onCheckedChange however how can I find out which checkbox was clicked? Thanks in advance!
You can try
CheckBox checkBox = (CheckBox)sender;
var id = checkBox.Attributes["data-id"];
Maybe you should redesign your UI architecture, as it's not acceptable to cause a full post back only for a change of a CheckBox (which is a Boolean parameter). I think you can use ajax here:
$(function(){
$('input[type=checkbox]').click(function(){
// Initializing an ajax call here, and updating DOM based on response.
});
});