I have this code that creates a check box an image and a label.
I want to view only three cells in each row, how can I do that??
<table class="checkbox-container" style="margin-top: 15px; width: 50%;">
<tr>
<asp:Repeater EnableViewState="true" ID="rptStart" runat="server">
<ItemTemplate>
<td style="width:25%;">
<asp:CheckBox ID="chkColor" runat="server" />
<img id="imgCompStatusStar" runat="server" enableviewstate="false" src="../images/" />
<asp:Label id="lblStarDescription" class="floating-left" runat="server" CssClass="test"/>
</td>
</ItemTemplate>
</asp:Repeater>
</tr>
</table>
Change your markup to this:
<asp:Repeater EnableViewState="true" ID="rptStart" runat="server">
<HeaderTemplate>
<table>
<tr>
</HeaderTemplate>
<ItemTemplate>
<%#If((Container.ItemIndex <> 0 AndAlso Container.ItemIndex Mod 3 = 0), "</tr><tr>", String.Empty)%>
<td style="width: 25%;">
<asp:CheckBox ID="chkColor" runat="server" />
<img id="imgCompStatusStar" runat="server" enableviewstate="false" src="../images/" />
<asp:Label ID="lblStarDescription" class="floating-left" runat="server" CssClass="test" />
</td>
</ItemTemplate>
<FooterTemplate>
</tr></table>
</FooterTemplate>
Related
I want to display records in Horizontal Layout. I used Data List control for the same which displays only 5 records.
I want select functionality so that when i click the items in Data List , complete details will be displayed in another page.
Thanks a lot.
<div style="margin-left: 25%; margin-top: 5%">
<asp:DataList ID="dlTop5" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow" RepeatColumns="5"
ItemStyle-Width="40%" >
<ItemTemplate>
<table>
<tr>
<td rowspan="3" style="margin-left: 3%">
<asp:ImageButton ID="imgServant" runat="server" ImageUrl='<%#Eval("photo")%>' Height="150px"
Width="150px" />
</td>
<td style="width: 50%">
<asp:Label ID="lblName" runat="server" Text='<%#Eval("name")%>' Font-Bold="true"
ForeColor="BlueViolet"></asp:Label>
</td>
</tr>
<tr>
<td style="width: 50%">
<asp:Label ID="lblPhone" runat="server" Text='<%#Eval("phone")%>' ForeColor="BlueViolet"> </asp:Label>
</td>
</tr>
<tr>
<td style="width: 50%">
<asp:Label ID="lblSrno" runat="server" Text='<%#Eval("sysno")%>'> </asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
<FooterTemplate>
<asp:Button ID="btnViewMore" runat="server" Text="View More" />
</FooterTemplate>
</asp:DataList>
</div>
</asp:Content>
This is what I do ...
<asp:DataList ID="DataList1" runat="server" BorderColor="Black" BorderWidth="1px"
DataSourceID="SqlDataSource2" GridLines="Both" RepeatDirection="Horizontal"
ShowFooter="False" ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Eval("RollCallPeriod") %>' OnClick="LinkButton1_Click"></asp:LinkButton><br />
</ItemTemplate>
</asp:DataList><asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ATCNTV1ConnectionString %>"
SelectCommand="SELECT RollCallPeriod FROM tblBoardingRollCallPeriods">
</asp:SqlDataSource>
And use the OnClick event to fire up a call into your code behind to reveal a panel for example and put all your specific code about the selection inside the panel - ie: Gridview, etc.
You don't have to use a LinkButton of course. It can be anything you want - a button, a hyperlink, etc
Labels do not have OnClick etc. Unless you "trap" them using JavaScript like mouseclick or mouseover.
i have this listview with news...
But each new news is in the new row...
I need 3 news in each row...
<asp:ListView ID="ListView2" runat="server" DataKeyNames="ID" DataSourceID="SqlDataSource1">
<AlternatingItemTemplate>
<table>
<tr>
<td>
<asp:Label ID="NovinkaLabel" runat="server" Text='<%# Eval("Novinka") %>' />
</td>
</tr>
</table>
</AlternatingItemTemplate>
<ItemTemplate>
<table>
<tr>
<td>
<asp:Label ID="NovinkaLabel" runat="server" Text='<%# Eval("Novinka") %>' />
</td>
</tr>
</table>
</ItemTemplate>
<LayoutTemplate>
<table id="Table2" runat="server">
<tr>
<td>
</td>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
This listview write each new into next row...but i need THREE news into ONE ROW.
It is possible?
Try likes this !
<asp:ListView ID="ListView2" runat="server" DataKeyNames="ID" DataSourceID="SqlDataSource1">
<AlternatingItemTemplate>
<table>
<td>
<asp:Label ID="NovinkaLabel" runat="server" Text='<%# Eval("Novinka") %>' />
</td>
</table>
</AlternatingItemTemplate>
<ItemTemplate>
<table>
<td>
<asp:Label ID="NovinkaLabel" runat="server" Text='<%# Eval("Novinka") %>' />
</td>
</table>
</ItemTemplate>
<LayoutTemplate>
<table id="Table2" runat="server">
<tr>
<asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
or
Change your listView to datalist , reference HERE . It's what you need !
In a simple way ,
<asp:DataList ID="DataList1" runat="server" RepeatColumns="3"
RepeatDirection="Horizontal" DataKeyNames="ID" DataSourceID="SqlDataSource1">
<ItemTemplate>
<asp:Label ID="NovinkaLabel" runat="server" Text='<%# Eval("Novinka") %>' />
</ItemTemplate>
</asp:DataList>
On chkSubModuleView_CheckedChanged() event iwant to get the id of chkModule.Please tell me how to get the id or reference of parent checkbox on click of child checkbox in server side.How to distinguish between different modules .
enter code here
<asp:ListView ID="lvModule" runat="server">
<LayoutTemplate>
<table width="600px" border="0" cellpadding="0" cellspacing="0"
class="ListViewtable">
<tr>
<th style="width: 10%;">
Modules
</th>
</tr>
<asp:PlaceHolder ID="itemPlaceholder" runat="server">
</asp:PlaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<asp:CheckBox ID="chkModule" runat="server"
CausesValidation="false" AutoPostBack="true"
OnCheckedChanged="chkModule_CheckedChanged" >
</asp:CheckBox><asp:HiddenField ID="hfEntityName"
Value='<%# Eval("EntityName") %>' runat="server" />
<%# Eval("Title")%>
<asp:HiddenField ID="hfID" Value='<%# Eval("ID") %>'
runat="server" />
<asp:Label ID="label" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td colspan="2" style="padding-left: 20px;">
<asp:ListView ID="lvSubModule" runat="server">
<LayoutTemplate>
<table width="100%" cellspacing="0" border="0"
class="ListViewtableLayer2">
<tr>
<th style="width: 20%;">
Sub Module
</th>
<th style="width: 20%;">
<asp:CheckBox ID="chkSubModuleView"
Checked="true" runat="server" AutoPostBack="true"
OnCheckedChanged="chkSubModuleView_CheckedChanged" />
View
</th>
</tr>
<asp:PlaceHolder ID="itemPlaceholder"
runat="server"></asp:PlaceHolder>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<%# Eval("Title")%>
<asp:HiddenField ID="hfMenuID" Value='<%#
Eval("MenuID") %>' runat="server" />
<asp:HiddenField ID="hfName" Value='<%#
Eval("HeaderID") %>' runat="server" />
</td>
<td>
<asp:CheckBox ID="chkRead" runat="server"
AutoPostBack="true" Checked="true" CausesValidation="false"
OnCheckedChanged="chkRead_CheckedChanged"></asp:CheckBox>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</td>
</tr>
</ItemTemplate>
</asp:ListView>
change your checkbox property to
<asp:CheckBox ID="chkSubModuleView"
Checked="true" runat="server" AutoPostBack="true" Key='<%# Eval("ID")%>'
OnCheckedChanged="chkSubModuleView_CheckedChanged" />
In your .cs
protected void chkSubModuleView_CheckedChanged(object sender, EventArgs e)
{
CheckBox chk = (CheckBox)sender;
string yourID = chk.Attributes["Key"].ToString();
}
I am attempting to get the row and column location of a text boxes OntextChanged.
I can get the column location if I do this:
TextBox txtScore = sender;
ListViewItem item = (ListViewItem)txtScore.NamingContainer;
int col = ((ListView)item.NamingContainer).DataKeys(item.DataItemIndex).Values(0);
which works until I convert the snippet below to a user control.
Code Snippet
<asp:ListView ID="techs" runat="server" ItemPlaceholderID="lvItemPlaceholder" DataKeyNames="Number"
OnItemDataBound="techs_ItemDataBound">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="lvItemPlaceholder" />
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
Tech
<%# Eval("Number")%>
</td>
<td>
<asp:TextBox ID="tech" runat="server" Text='<%# Eval("Name") %>' />
</td>
<asp:ListView ID="scorePatterns" runat="server" ItemPlaceholderID="lvScorePatternsItemPlaceholder"
OnItemDataBound="scorePatterns_ItemDataBound" DataKeyNames="Ref">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="lvScorePatternsItemPlaceholder" />
</LayoutTemplate>
<ItemTemplate>
<td>
<table>
<asp:ListView ID="scores" runat="server" ItemPlaceholderID="lvScoresItemPlaceholder"
OnItemDataBound="scores_ItemDataBound" DataKeyNames="Ref,Instance">
<LayoutTemplate>
<asp:PlaceHolder runat="server" ID="lvScoresItemPlaceholder" />
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<asp:TextBox runat="server" ID="txtScore" Width="50" AutoPostBack="true" OnTextChanged="txtScore_TextChanged" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
</table>
</td>
</ItemTemplate>
</asp:ListView>
<td>
<asp:Label runat="server" ID="lblDate" Text='<%# Eval("Date") %>' />
</td>
</tr>
</ItemTemplate>
I Have A web Page Having Two TextBox and Two Image Button on Image Button Click
open the ModalPopupExtender having Grid inside the ModelPopExtender. mean Grid Pop open on image button CLick. Problem is That when i click the button It show ModelPopExtender and Close.
auto and Page Post Back and Again Pop open. I want that pop is open stage not to post back.
aspx Code is like:
"
<asp:ImageButton ID="imgbtnExpenseGL" runat="server" ImageUrl="../../Images/icon_popup.gif" ImageAlign="Top" OnClientClick="ShowPopupExpGLSearch();" />
<AjaxToolKit:AutoCompleteExtender
ID="AutoCompleteExtender1"
runat="server"
CompletionInterval="100"
CompletionSetCount="12"
EnableCaching="false"
MinimumPrefixLength="1"
ServiceMethod="GetGLAccountList"
TargetControlID="txtExpenseGL"
>
</AjaxToolKit:AutoCompleteExtender>
<AjaxToolKit:ModalPopupExtender
ID="ModalPopupExtender1"
runat="server"
BackgroundCssClass="modalBackground"
CancelControlID="btnCancelCountry"
DropShadow="true"
PopupControlID="divExpenseGLSearch"
TargetControlID="imgbtnExpenseGL">
</AjaxToolKit:ModalPopupExtender>
</ContentTemplate>
</asp:UpdatePanel>"
Thier two update panel like that having same code.
and This Grid Bind div Code:
<div id="divAccountGLSearch" class="popup" style="display: none; width: 350px;">
<table width="98%" align="center" border="0" cellpadding="0" cellspacing="0" style="height: 320px;">
<%-- For Heading and Image and CloseDiv --%>
<%-- Row 1 For Header Text --%>
<tr>
<th>
<h1>
List of Pre-Paid Account GL
</h1>
</th>
<td align="right" valign="top" style="padding-top: 6px;">
<img onclick="CloseDiv();" src="../../Images/close.gif" border="0" />
</tr>
<%-- Row 2 For Find TextBox and Find Button --%>
<tr>
<td class="form-label" style="padding-left: 5px;width:70%;">
Search
<asp:TextBox ID="txtFindPrePaidExpenses" runat="server" onBlur="javascript:setpopupfocus();" ></asp:TextBox>
</td>
<td align="left" style="width:30%;">
<table>
<tr>
<td>
<asp:LinkButton ID="btnFindCountry" CssClass="button" runat="server"
OnClientClick="ShowPopupAccGLSearch();" onclick="btnFindCountry_Click">
<span>Find</span></asp:LinkButton>
</td>
</tr>
</table>
</td>
</tr>
<%-- Row 3 For Repater Control --%>
<tr>
<td colspan="2" align="center">
<div style="overflow: auto; height: 280px; width: 100%;">
<asp:GridView ID="gvSearchAccountGL" runat="server" AutoGenerateColumns="False"
Width="98%" CssClass="table-grid" border="0" CellPadding="0"
CellSpacing="0" onrowdatabound="gvSearchAccountGL_RowDataBound"
>
<Columns>
<asp:TemplateField Visible="false">
<ItemTemplate>
<asp:HiddenField ID="hfIndex" runat="server" Value='<%# Container.DataItemIndex + 1 %>'/>
</ItemTemplate>
<HeaderStyle HorizontalAlign="left" />
<ItemStyle HorizontalAlign="left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Account GL">
<ItemTemplate>
<asp:Label ID="lblAccountGLCode" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ACM_ACCOUNT_CODE")%>' ></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="left" />
<ItemStyle HorizontalAlign="left" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Account Description">
<ItemTemplate>
<asp:Label ID="lblAccountGLDescription" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ACM_ACCOUNT_DESC")%>' ></asp:Label>
</ItemTemplate>
<HeaderStyle HorizontalAlign="left" />
<ItemStyle HorizontalAlign="left" />
</asp:TemplateField>
</Columns>
<RowStyle CssClass="gridRow" />
<HeaderStyle CssClass="gridHeader" />
<SelectedRowStyle BackColor ="Gray" />
</asp:GridView>
</div>
</td>
</tr>
<%-- Row 4 For Space Image --%>
<tr>
<td colspan="2">
<img src="../../Images/spacer.gif" border="0" class="seprator" />
</td>
</tr>
<%-- Row 5 For OK and Cancel Button --%>
<tr>
<td colspan="2">
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
<asp:LinkButton ID="btnOKPrePaidExpense" CssClass="button" runat="server"
onclick="btnOKPrePaidExpense_Click">
<span>OK</span></asp:LinkButton>
</td>
<td>
</td>
<td>
<asp:LinkButton ID="btnCancelPrePaidExpense" CssClass="button" runat="server">
<span>Cancel</span></asp:LinkButton>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
My div Bind Code is Out off Update Panel Code.
so how to stop postback and Stable Pop Control
Thank U
To prevent the ImageButton control from automatically posting back when it's clicked, your ShowPopupExpGLSearch() function should return false.