I have a repeater which has table as per below code and I need to send param to code behind when table row is clicked.
At the moment I am passing it on LinkButton1 click.
I have also tried wrapping in LinkButton but it's not working
How do I do this?
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand" OnItemDataBound="Repeater1_ItemDataBound" OnItemCreated="Repeater1_ItemCreated">
<HeaderTemplate>
<table class="table table-striped table-bordered dttable dataTable no-footer" style="border-style: solid; border-color: rgb(252, 253, 250); text-align: center; font-weight: 700; width: 100%;" id="JsDataTable" role="grid" aria-describedby="JsDataTable_info">
<thead style="width: 100%">
<tr style="color: #fff; width: 100%;">
<td id="tdSr">Sr</td>
<td id="tdCode" style="white-space: nowrap;">
<asp:LinkButton ID="lnCode" runat="server" CommandName="CourseNo" CssClass="linkHeader">Code<i class = "fa fa-fw fa-sort" ></i></asp:LinkButton>
</td>
<td id="tdName" style="width: 50%; white-space: nowrap; text-align: left;">
<asp:LinkButton ID="lnName" runat="server" CommandName="VName" CssClass="linkHeader">Name<i class = "fa fa-fw fa-sort" ></i></asp:LinkButton>
</td>
<td id="tdType" style="width: 20%">
<asp:LinkButton ID="lnType" runat="server" CommandName="VType" CssClass="linkHeader">Type<i class = "fa fa-fw fa-sort" ></i></asp:LinkButton>
</td>
</tr>
</thead>
<tbody style="width: 100%">
</HeaderTemplate>
<ItemTemplate>
<tr id="trID" runat="server" class="box" style="height: 30px; color: #08516F; vertical-align: middle;">
<td style="color: #004457; border-right: 1px solid #004457; vertical-align: middle;" class="labelTxt">
<asp:HiddenField ID="hfAllowSubscription" runat="server" Value='<%#Eval("AllowSubscription") %>' />
<asp:Label ID="lblSR" runat="server"></asp:Label>
</td>
<td style="color: #004457; border-right: 1px solid #004457; vertical-align: middle;">
<%#Eval("CourseNo") %>
</td>
<td style="color: #004457; border-right: 1px solid #004457; text-align: left !important; vertical-align: middle;">
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="PlayPrev" CommandArgument='<%#Eval("Id") %>' Text='<%#Eval("Name") %>' CssClass="name"></asp:LinkButton>
</td>
<td style="color: #004457; border-right: 1px solid #004457; vertical-align: middle;">
<asp:Label Text='<%#Eval("VType") %>' runat="server" ID="lblType" CssClass="lblType" Style="font-family: 'Segoe UI semiBold' !important;"></asp:Label>
<span id="lblsubtype" runat="server" class="subtype_color T"></span>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
<div id="repeatorEmptyRow" runat="server" style="text-align: center; color: red;">
No matching records found
</div>
</FooterTemplate>
</asp:Repeater>
I'm guessing you want the value of the CommandArgument in Repeater1_ItemCommand. But if you try to cast the sender to a LinkButton that will not work because the Sender is the Repeater, not the button inside.
So cast the CommandSource and get the correct value.
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
LinkButton lb = e.CommandSource as LinkButton;
Label1.Text = lb.CommandArgument;
}
You cannot bind a tr click directly, so you have to use a trick. You can use jQUery to set the click of the LinkButton to the row itself.
<table border="1" id="Repeater1Table">
<asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<tr>
<td>Click here</td>
<td>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="PlayPrev" CommandArgument='<%#Eval("Id") %>' Text='<%#Eval("Name") %>' CssClass="name"></asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
<script type="text/javascript">
$(document).ready(function () {
$("#Repeater1Table tr").each(function () {
var href = $(this).find(".name").prop("href").split(":")[1];
$(this).attr("onclick", href);
});
});
</script>
Related
I have a listview that I bind using custom code in the code behind. The listview has a datapager and needs to be sorted.
I created a custom sort routine that successfully sorts the list view. The issue is that if I change the page using the datapager, the sort is not maintained (i.e. page 2 and up are not sorted)
Here is the code for the list view:
<asp:ListView ID="lv_positions_i_posted" runat="server" DataKeyNames="postingid" OnPagePropertiesChanging="lv_positions_i_posted_paging" OnItemDataBound="lv_positions_i_posted_ItemDataBound">
<LayoutTemplate>
<table id="Table2" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table id="itemPlaceholderContainer" runat="server" border="1"
style="border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px; font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr>
<th colspan="2" style="background-color: darkseagreen;">Posting </th>
<th colspan="1" style="background-color: sandybrown;">Applications </th>
<th colspan="4">Positions I Posted </th>
</tr>
<tr id="Tr2" runat="server" style="color: #000000;">
<th id="Th1" runat="server" style="background-color: darkseagreen;">View </th>
<th id="Th2" runat="server" style="background-color: darkseagreen;">Edit </th>
<th id="Th3" runat="server" style="background-color: sandybrown;">View </th>
<th id="Th4" runat="server">ID </th>
<th id="Th6" runat="server">Title </th>
<th id="Th8" runat="server">Posting Date
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="conditional">
<ContentTemplate>
<asp:ImageButton ID="SortPostingButton" runat="server" ImageUrl="~/images/Up2.png" Height="20px" Width="20px" ToolTip="Sort" OnClick="PostingSort1_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="SortPostingButton" />
</Triggers>
</asp:UpdatePanel>
</th>
<th id="Th9" runat="server">Status
<asp:ImageButton ID="SortStatusButton" runat="server" ImageUrl="~/images/Up2.png" Height="20px" Width="20px" ToolTip="Sort" OnClick="StatusSort1_Click" />
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr3" runat="server">
<td id="Td2" runat="server"
style="text-align: center; background-color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000;">
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="lv_positions_i_posted" PageSize="20">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
<asp:NumericPagerField ButtonCount="10" />
<asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True"
ShowNextPageButton="False" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr style="background-color: #DCDCDC; color: #000000; font-weight: normal;">
<td style="text-align: center">
<asp:ImageButton ID="ViewPostingButton" runat="server" ToolTip="View Posting" ImageUrl="~/images/green-eye-icon-new-small.png" Width="30px" Height="18.75px" OnCommand="ViewPostingButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:ImageButton ID="EditPostingButton" runat="server" ToolTip="Edit Posting" ImageUrl="~/images/pencil_small.png" Width="18.75px" Height="18.75px" OnCommand="EditPostingButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:ImageButton ID="ViewPostingApplicantButton" runat="server" ToolTip="View Applicants" ImageUrl="~/images/green-eye-icon-new-small.png" Width="30px" Height="18.75px" ImageAlign="Middle" OnCommand="ViewPostingApplicantButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:Label ID="PostingID" runat="server" Text=' <%# Eval("PostingID") %>' Visible="true" />
</td>
<td>
<asp:Label ID="PostingTitle" runat="server" Text=' <%# Eval("PostingTitle") %>' Visible="true" ToolTip=' <%# Eval("PostingTitleFull") %>' />
</td>
<td style="text-align: center">
<asp:Label ID="PostingDate" runat="server" Text=' <%# Eval("PostingDate","{0:MM/dd/yyyy}") %>' Visible="true" />
</td>
<td style="text-align: center">
<asp:Label ID="PostingStatusID" runat="server" Text=' <%# Eval("PostingStatusID") %>' Visible="true" />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color: #FFF8DC; color: #000000; font-weight: normal;">
<td style="text-align: center">
<asp:ImageButton ID="ViewPostingButton" runat="server" ToolTip="View Posting" ImageUrl="~/images/green-eye-icon-new-small.png" Width="30px" Height="18.75px" OnCommand="ViewPostingButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:ImageButton ID="EditPostingButton" runat="server" ToolTip="Edit Posting" ImageUrl="~/images/pencil_small.png" Width="18.75px" Height="18.75px" OnCommand="EditPostingButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:ImageButton ID="ViewPostingApplicantButton" ToolTip="View Applicants" runat="server" ImageUrl="~/images/green-eye-icon-new-small.png" Width="30px" Height="18.75px" ImageAlign="Middle" OnCommand="ViewPostingApplicantButton_Click" CommandArgument=' <%#Eval("PostingID")%>' />
</td>
<td style="text-align: center">
<asp:Label ID="PostingID" runat="server" Text=' <%# Eval("PostingID") %>' Visible="true" />
</td>
<td>
<asp:Label ID="PostingTitle" runat="server" Text=' <%# Eval("PostingTitle") %>' Visible="true" ToolTip=' <%# Eval("PostingTitleFull") %>' />
</td>
<td style="text-align: center">
<asp:Label ID="PostingDate" runat="server" Text=' <%# Eval("PostingDate","{0:MM/dd/yyyy}") %>' Visible="true" />
</td>
<td style="text-align: center">
<asp:Label ID="PostingStatusID" runat="server" Text=' <%# Eval("PostingStatusID") %>' Visible="true" />
</td>
</tr>
</AlternatingItemTemplate>
<EmptyDataTemplate>
<table id="Table1" runat="server"
style="background-color: #FFFFFF; border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;">
<tr>
<td>No data was returned. </td>
</tr>
</table>
</EmptyDataTemplate>
</asp:ListView>
Here is where I capture the sort:
protected void PostingSort1_Click(object sender, ImageClickEventArgs e)
{
if (TheListView.Text == "1")
{
if (LastSortField.Text == "p.postingdate")
{
if (LastSortDirection.Text == "asc")
{
ImageButton button = (ImageButton)sender;
button.ImageUrl = "~/images/Down2.png";
}
else
{
ImageButton button = (ImageButton)sender;
button.ImageUrl = "~/images/Up2.png";
}
}
}
currentLV = TheListView.Text;
BindListview(currentLV, "p.postingdate");
}
Here is where I bind/re-bind the listview:
protected void BindListview(string selectedItem, string orderby)
{
string SQL = "";
string direction = "";
SQL = "Select Statment Here";
if (orderby != "")
{
if (selectedItem == TheListView.Text)
{
if (orderby == LastSortField.Text)
{
if (LastSortDirection.Text == "asc")
{
direction = "desc";
}
else
{
direction = "asc";
}
SQL += " Order by " + orderby + " " + direction;
LastSortDirection.Text = direction;
LastSortField.Text = orderby;
}
else
{
SQL += " Order by " + orderby;
LastSortDirection.Text = "asc";
LastSortField.Text = orderby;
}
}
else
{
SQL += " Order by '" + orderby ;
LastSortDirection.Text = "asc";
LastSortField.Text = orderby;
}
}
else
{
SQL += " Order by PostingID asc";
LastSortDirection.Text = "asc";
LastSortField.Text = "PostingID";
}
DataSet ds = jdh.GetDataSetFromDB(SQL);
lv_positions_i_posted.DataSource = ds;
lv_positions_i_posted.DataBind();
lv_positions_i_posted.Visible = true;
ds.Dispose();
}
As I indicated, the displayed listview data is sorted correctly EXCEPT it is not being maintained when I use the datapager. I am expecting that the entire listview is sorted correctly throughout the paged data.
I figured it out. I forgot that I captured the datapager page change and was not passing in the "orderby" variable. Once I fixed that it works correctly.
protected void lv_positions_i_manage_paging(object sender, PagePropertiesChangingEventArgs e)
{
(lv_positions_i_manage.FindControl("DataPager1") as DataPager).SetPageProperties(e.StartRowIndex, e.MaximumRows, false);
if (LastSortDirection.Text == "asc")
{
LastSortDirection.Text = "desc";
}
else
{
LastSortDirection.Text = "asc";
}
BindListview("2", LastSortField.Text);
}
today i have certain problem using user control (.ascx) in asp.net technology. currently, i have scenario where the ideas are to put modal jquery mobile modal into ascx. then save the data based on click. for this condition, i have this coding
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="IndexPanel1.ascx.cs" Inherits="WebPGN.Pages.control.indexPanel1" %>
<style>
.btn-size {
width: 50px !important;
}
</style>
<div>
<i class="icon-pencil"></i>
<div data-role="popup" id="myPopup" style="width: 1000px;" data-history="false">
<div class="modal-header">
<h4 style="font-family: '__Helvetica Neue LT Std_5'; font-weight: 500; font-size: 16px;"><i class="icon-edit"></i> Edit Information</h4>
Close
</div>
<div class="modal-body">
<div class="col-md-12">
<table class="table table-responsive" border="0" style="border-color: #FFFFFF;">
<tr class="form-group">
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 10%;">Header Text</td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 30%;">
<asp:TextBox runat="server" ID="txt_Panel1_Header_Eng" Visible="true" EnableViewState="true" ClientIDMode="Static" />
</td>
<td style="width: 3%; border-top: 0px solid #f4f4f4 !important;"></td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 10%;">Judul Teks</td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 30%;">
<asp:TextBox runat="server" ID="txt_Panel1_Header" ClientIDMode="Static" />
</td>
</tr>
<tr class="form-group">
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 10%;">Body Text</td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 30%;">
<textarea rows="6" cols="90" id="txt_Panel1_Body_Eng" runat="server" style="height: 250px;"></textarea>
</td>
<td style="width: 3%; border-top: 0px solid #f4f4f4 !important;"></td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 10%;">Konten Teks</td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 30%;">
<textarea rows="6" cols="90" id="txt_Panel1_Body" runat="server" style="height: 250px;"></textarea>
</td>
</tr>
<tr class="form-group">
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 10%;">Tag</td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 30%;">
<asp:TextBox runat="server" ID="txt_Panel1_Tag_Eng" ClientIDMode="Static"/>
</td>
<td style="width: 3%; border-top: 0px solid #f4f4f4 !important;"></td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 10%;">Label</td>
<td style="vertical-align: middle; border-top: 0px solid #f4f4f4 !important; font-family: '__Helvetica Neue LT Std_5'; font-weight: 300; width: 30%;">
<asp:TextBox runat="server" ID="txt_Panel1_Tag" ClientIDMode="Static"/>
</td>
</tr>
</table>
</div>
</div>
<div class="modal-footer" style="border-top: 0px solid #e5e5e5;" id="modal-footer">
<a class="btn btn-primary" href="#myPopup" data-rel="back" style="color: #fff;">Cancel</a>
<a class="btn btn-primary" href="#myPopup" ID="btnSaveHomePanel1" data-rel="back" runat="server" style="color: #fff;">Save</a>
</div>
</div>
</div>
for some reason, i want to use this ascx for example to send data to the server side. however, i have problem because when using asp.net button, the event doesnot fire back. can anyone give me more advice to accomplish this current condition. or should i use bootstrap modal rather than jquery mobile ui ? and how to use ascx as modal ? thank you very much :)
PS: i am using
<link rel="stylesheet" href="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
you have to try bootstrap Modal like
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script
src="https://code.jquery.com/jquery-2.2.4.js"
integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI="
crossorigin="anonymous"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<asp:LinkButton ID="btn_SearchCriteria" runat="server" Text="Search Vehicles" data-toggle="modal" data-target="#myModal"><p class="btn btn-primary">Purchasing Tool</p></asp:LinkButton>
<div aria-labelledby="myModalLabel" class="modal fade" id="myModal" role="dialog" tabindex="-1">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 style="font-size: 18px; font-weight: 600">Purchasing Tool and Analysis</h1>
<button type="button" class="close pull-right" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<asp:Panel ID="pnlSubItems" runat="server" CssClass="modalBox" Width="100%">
<asp:Repeater runat="server" ID="repVehicleInfo" OnItemDataBound="repVehicleInfo_ItemDataBound">
<ItemTemplate>
<ul class="media-list">
<li class="media">
<div class="media-left">
<img src="../../images/SystemImages/car-avatar.png" style="width: 250px; height: 200px" />
<br />
<asp:Label ID="lbl_stockno" runat="server" Style="font-weight: 600" Text='<%# Bind("StockNumber") %>'></asp:Label>
</div>
<div class="media-body">
<%--2001 Holden Astra TS 12/00-12/04--%>
<h1 class="media-heading" style="font-weight: 600">
<asp:Label ID="lbl_heading" runat="server" Text='<%# Bind("Description") %>'></asp:Label></h1>
<div class="col-sm-8">
<table class="table table-responsive">
<tr>
<td>Body Style:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_bodystyle" runat="server" Text='<%# Bind("BodyType") %>'></asp:Label>
</td>
</tr>
<tr>
<td>Engine:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_engine" runat="server" Text='<%# Bind("Engine") %>'></asp:Label>
</td>
</tr>
<tr>
<%-- <td>License No:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_linceno" runat="server"></asp:Label>
</td>--%>
<td>Transmission:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_transmission" runat="server" Text='<%# Bind("Engine") %>'></asp:Label>
</td>
</tr>
<tr>
<%-- <td>Reg No:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_regno" runat="server"></asp:Label>
</td>--%>
<td>Odometer:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_odometer" runat="server" Text='<%# Bind("Odometer") %>'></asp:Label>
</td>
</tr>
<tr>
<%-- <td>Color:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_color" runat="server"></asp:Label>
</td>--%>
<td>Purchased From:</td>
<td style="font-weight: 600">
<asp:Label ID="lbl_PurchasedFrom" runat="server" Text='<%# Bind("PurchasedFrom") %>'></asp:Label>
</td>
</tr>
<tr>
<td>Purchase Amount:</td>
<td style="font-weight: 600">$<asp:Label ID="lbl_PurchaseAmount" runat="server" Text='<%# Bind("PurchaseAmount") %>'></asp:Label>
</td>
</tr>
<tr>
<td>Sale Amount:</td>
<td style="font-weight: 600">$<asp:Label ID="lbl_SaleAmount" runat="server" Text='<%# Bind("SalesAmount") %>'></asp:Label>
<button id="lbtn_makemodel" href="#makemodel" type="button" class="btn btn-sm btn-primary pull-right" data-toggle="modal">
<i class="fa fa-cogs" aria-hidden="true"></i>Make/Model</button>
</td>
</tr>
<tr>
<td>Estimated Profit:</td>
<td style="font-weight: 600">
$<asp:Label ID="lbl_Estimatedprofit" runat="server" Text='<%# Bind("EstimatedProfit") %>'></asp:Label>
<button id="lbtn_anaylse" href="#anaylse" type="button" class="btn btn-sm btn-primary pull-right" data-toggle="modal"><i class="fa fa-pie-chart" aria-hidden="true"></i>Anaylse</button>
</td>
</tr>
<tr>
<td>App Price:</td>
<td style="font-weight: 600">
$<asp:Label ID="lbl_AppPrice" runat="server" Text='<%# Bind("PurchaseAmount") %>'></asp:Label>
</td>
</tr>
</table>
</div>
<div class="col-sm-4">
<asp:Repeater runat="server" ID="repPartsDetail">
<HeaderTemplate>
<ul class="list-group">
</HeaderTemplate>
<ItemTemplate>
<li class="list-group-item">
<asp:Label ID="lbl_Partname" runat="server" Text="Engine" />
<span class="badge">
$<asp:Label ID="lbl_partprice" runat="server" Text="0" Style="float: right;" />
</span>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
</div>
</div>
</li>
</ul>
</ItemTemplate>
</asp:Repeater>
</asp:Panel>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
First of all add Bootstrap CSS and Bootstrap JS.
then Use this code
This code work for me. like when i click on linked button Bootstrap Modal Show
you can use this Webcontrol Any where and bind data on CodeBhind in ascx.cs file
New to using the ListView control and I'm trying to retrieve the value of some textboxes in the layout template. Here's my aspx code:
<asp:ListView
ID="lvFundingSummary"
OnItemCommand="lvFundingSummary_onItemCommand"
OnItemDataBound="lvFundingSummary_ItemDataBound"
runat="server" >
<EmptyDataTemplate>
<table
id="Table1"
runat="server"
style="background-color: #FFFFFF;
border-collapse: collapse;
border-color: #999999;
border-style:none;
border-width:1px;">
<tr>
<td>No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<tr>
<td style="width: 50%; text-align:left; padding-top: 5px; padding-bottom:5px;">
<asp:Label ID="lblResearchArea" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "PlName")%>' />
</td>
<td style="width: 30%; text-align:right; padding-top: 5px; padding-bottom:5px;">
<asp:Label ID="lblFundingGross" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "FundingGross", "{0:c}")%>' />
</td>
<td style="width: 20%; text-align:right; padding-top: 5px; padding-bottom:5px;">
<asp:Label ID="lblGross" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "AllGross", "{0:c}")%>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table id="Table2" style="width: 90%" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server" width="100%">
<table
ID="itemPlaceholderContainer"
runat="server"
style="width: 98%">
<tr id="TrHeading" runat="server">
<th id="Th1" style="width: 50%; text-align:left;" runat="server">
Research Area</th>
<th id="Th2" style="width: 30%; text-align:right;" runat="server">
Gross</th>
<th id="Th3" style="width: 20%; text-align:right;" runat="server">
All Gross</th>
</tr>
</table>
<div style="overflow-y:scroll; height:400px;">
<table style="border: 10px; width: 100%">
<tr ID="itemPlaceholder" runat="server"></tr>
</table>
</div>
</td>
</tr>
<tr id="Tr2" runat="server">
<td id="Td2" runat="server"
style="text-align: center;background-color: #5D7B9D;font-family: Verdana, Arial, Helvetica, sans-serif;color: #FFFFFF">
</td>
</tr>
<tr id="TrFooter" runat="server">
<td style="width: 50%; text-align:left;">
<b>Total(s)</b>
</td>
<td id="TdTotal" style="width: 30%; text-align:right;">
<b>
<asp:Label ID="lblTotalFunding" runat="server" /></b>
</td>
<td id="TdTotal" style="width: 20%; text-align:left;">
<b>
<asp:Label ID="lblTotalGross" runat="server" /></b>
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
in the lvFundingSummary_PreRender event, I'm trying to access the control as such:
Label lbTotFund = this.lvFundingSummary.FindControl("TrFooter").FindControl("lblTotalFunding") as Label
but that's not working. I know this should be a snap, just can't quite seem to find it.
According to this post, use
var lbTotFund = lvFundingSummary.FindControl("lblTotalFunding") as Label;
in lvFundingSummary_LayoutCreated event, it should do the work
I have the following Updatepanel:
<asp:UpdatePanel ID="upPopUps" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="panelOverlay" runat="server" class="Overlay" Visible="false">
</asp:Panel>
<asp:Panel ID="panelPopUpPanel" runat="server" class="PopUpPanel" Visible="false"
BorderStyle="Solid" BorderWidth="5px" Height="250px">
<table style="width: 100%; height: 100%; border-bottom: solid 2; border-top: solid 2;
border-left: solid 2; border-right: solid 2;">
<tr>
<th style="width: 100%; padding-left: 10px;" colspan="2">
<asp:PlaceHolder ID="PopupHeader" runat="server"></asp:PlaceHolder>
</th>
<th>
<asp:ImageButton id="cmdClosePopUp" runat="server" src="../Navigation/PopupImages/Close.png" alt="Close Popup"
OnClick="ClosePopup" align="right" />
</th>
</tr>
<tr class="border_top">
<td colspan="3">
</td>
</tr>
<tr style="height: 80%">
<td align="center">
<asp:PlaceHolder ID="PopupMessage" runat="server"></asp:PlaceHolder>
</td>
</tr>
<tr style="height: 10%">
<td colspan="3" style="padding-left: 10px;">
<input type="hidden" id="StartDivID" value="0" runat="server" />
<input type="hidden" id="NewsCount" value="" runat="server" />
<asp:ImageButton runat="server" id="btn_ok" src="../Navigation/PopupImages/Ok_Button.jpg" alt="Close Popup"
OnClick="ClosePopup" align="right" />
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
My problem is that if i click on one of these two Buttons after PageLoad it works fine.
Through $(document).ready(function() i refresh the Page every 60 seconds. The PopUp pops up, but the Buttons do not fire anymore.
$(document).ready(function() {
setInterval("RefreshGrid()", 60000);
});
function RefreshGrid() {
var WebGrid1 = ISGetObject("WebGrid1");
WebGrid1.Refresh();
}
Do someone has an idea, where could be the problem? Why is it only working on the first pageload?
There's a reserved function called pageLoad that runs at every postback. Bind your events inside it.
function pageLoad() {
$('#btn_ok, #cmdClosePopUp').click(ClosePopup); //Something like this.
}
It feels like you're losing the link to the handlers when you refresh. This should fix that.
I am trying to make the row background color change when moseover, but I could not make it work. I am not sure I use OnItemDataBound is correct or my codebehind is incorrect.
Please help. Thanks!
<asp:DataList BackColor="#ffffff" id="DataList1" DataSourceID="dsCompanyListPartialMatch" runat="server" Width="80%" DataKeyField="Company1Word"
UseAccessibleHeader="true"
CssClass="books"
HeaderStyle-CssClass="header"
ItemStyle-CssClass="item"
AlternatingItemStyle-CssClass="alternating"
GridLines="Both"
CellPadding="0"
CellSpacing="0" BorderColor="Black"
ItemStyle-BorderColor="Black" BorderWidth="0"
HorizontalAlign="Center"
RepeatDirection="Vertical"
OnItemDataBound="DataList1_ItemDataBound"
>
<HeaderTemplate>
</HeaderTemplate>
<ItemStyle BorderColor="black" Font-Size="Medium" />
<ItemTemplate>
<table border="0">
<tr>
<td style="width: 50px; border-right:1px solid black; border-spacing:0; text-align:center; ">
<asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" Text="+" CommandArgument='<%#Container.ItemIndex%>'
OnCommand="LinkButton1_Command"
Font-Underline="false"
Height="25"
Font-Bold="true"
></asp:LinkButton>
</td>
<td style="width: 50px; border-right:1px solid black; border-spacing:0;"><%#Eval("Row")%></td>
<td style="width: 800px"><asp:Literal ID="litFoo" runat="server" Text='<%#Eval("Company")%>' /> </td>
<td style="width: 600px; text-align:right;">
<asp:CheckBox id="check1" runat="server" />
</td>
<asp:Label ID="lblRow" Visible="False" runat="Server" Text='<%# DataBinder.Eval(Container.DataItem, "Row") %>' />
</tr>
</table>
<asp:Panel ID="pnlChildView" runat="server" style="padding-left:200px;">
<asp:DataList ID="childList" runat="server" Width="100%">
<ItemTemplate>
<table class="table1" border="1">
<tr>
<td style="width: 800px; border-right:0px solid black; border-spacing:0;">• <%#Eval("CompanyName")%></td>
<td style="text-align:right; "><a href="/Apps/ERP/Other/CompanyInfo.asp?CompanyID=<%#Eval("CompanyID")%>" ><%#Eval("CompanyID")%></a></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</asp:DataList>
Code behind
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item)
{
e.Item.Attributes.Add("onmouseover", "this.className='BGMouseOver'");
e.Item.Attributes.Add("onmouseout", "this.className='BGMouseOut'");
}
}
Try jQuery mouseover() Method
Click here
I suggest CSS. You can find the idea here: div background color, to change onhover
Add CSS to the top:
<style type="text/css">
.div_hover:hover { background-color: #000000; } <-- this is where you set your hover color
</style>
Basically, wrap everything in your ItemTemplate in a div, like so:
<ItemTemplate>
<div class="div_hover">
[ItemTemplate stuff...]
</div>
</ItemTemplate>