Fix datalist single item layout while printing - asp.net

I have a datalist where i m displaying 8 items for printing.I m printing two items per row.When i print a two or more than two items,the layout is perfect.but when i print single item.the layout changes and expands.How Can i fix it for single item also.
<asp:DataList ID="datalis1" runat="server" RepeatDirection="Horizontal"
BorderStyle="NotSet" CellPadding="0" CellSpacing="5" RepeatLayout="Table"
RepeatColumns="2" >
<ItemStyle />
<ItemTemplate>
<asp:Panel ID="Panel1" runat="server" CssClass="boxdiv">
<table style="width: 94%;" align="center" cellspacing="0" cellpadding="0" border="0" class="table1">
<tr style="height:2px;">
<td colspan="0" rowspan="0" height='2px'>
<asp:Label ID="lblwebsite" runat="server" Font-Bold="True" Text='<% # bind("website")%>'>
</asp:Label>
</td>
</tr>
<tr style="height:2px;" >
<td colspan="0" rowspan="0" height='2px'>
<asp:Label ID="Label13" runat="server" Font-Bold="True" Text="Call #">
</asp:Label>
<asp:Label ID="lblcontact" runat="server" Text='<% # bind("mobile1")%>'>
</asp:Label>
<asp:Label ID="Label15" runat="server" Font-Bold="True" Text="Fax #">
</asp:Label>
<asp:Label ID="lblfax" runat="server" Text='<% # bind("fax")%>'>
</asp:Label>
</td>
</tr>
<tr style="height:2px;">
<td colspan="0" rowspan="0" height='2px' >
<%--<asp:Label ID="lblfax0" runat="server" Font-Bold="True" Text="Address :">
</asp:Label>--%>
<asp:Label ID="lbladdress" runat="server" Text='<% # bind("address")%>' ></asp:Label>
</td>
</tr>
<tr style="height:4px;">
</tr>
<tr style="height:4px;">
</tr>
<tr style="height:2px;">
<td height='2px' >
<asp:Label ID="lblfax1" runat="server" Font-Bold="True" Text="Ord #">
</asp:Label>
<asp:Label ID="lblorder" runat="server" text='<% # bind("orderno")%>'>
</asp:Label>
<asp:Label ID="lblfax2" runat="server" Font-Bold="True" Text="Dt:">
</asp:Label>
<asp:Label ID="lblvrdate" runat="server" Text='<% # bind("vr_date")%>'>
</asp:Label>
</td>
</tr>
<tr >
<td height='2px' >
<asp:Label ID="lblfax3" runat="server" Font-Bold="True" Text="Pt:">
</asp:Label>
<asp:Label ID="lblpt" runat="server" Text='<% # bind("pname")%>' Font-Bold="False" >
</asp:Label>
<asp:Label ID="Label16" runat="server" Font-Bold="True" Text="Dr :">
</asp:Label>
<asp:Label ID="lbldrname" Text='<% # bind("drname")%>' runat="server" Font-Bold="False" >
</asp:Label>
</td>
</tr>
<tr style="height:4px;" >
</tr>
<tr style="height:4px;" >
</tr>
<tr >
<td height='2px'>
<asp:Label ID="Label17" runat="server" Font-Bold="True"
Text="Rx:"></asp:Label>
<asp:Label ID="lblorderSupplied" runat="server" Font-Bold="False" Text='<% # bind("medicine")%>'
></asp:Label> <br />
<asp:Label ID="labeld" runat="server" Text="Qty:" Font-Bold="True"></asp:Label>
<asp:Label ID="lblpack" Text='<% # bind("pack")%>' runat="server" ></asp:Label>
<asp:Label ID="txtmfgDt" runat="server" text="x"> </asp:Label>
<asp:Label ID="lblqty" runat="server" text='<% # bind("suppquantity")%>'></asp:Label>
</td>
</tr>
<tr style="height:4px;" >
</tr>
<tr style="height:4px;" >
</tr>
<tr >
<td height='2px'>
<%-- <asp:Label ID="Label18" runat="server" Font-Bold="True"
Text="Directions:"></asp:Label>--%>
<%-- <div style="text-overflow : ellipsis; overflow: hidden; overflow-y: hidden; height:38px">--%>
<asp:Label ID="lbldirections" Height="38PX" Text='<% # bind("directions")%>' runat="server" Font-Bold="False"></asp:Label>
<%-- </div>--%>
</td>
</tr>
<tr >
<td height='2px'>
<%-- <asp:Label ID="lblmfg" runat="server" text="Mfg:"></asp:Label>--%>
</td>
</tr>
</table>
</asp:Panel>
</ItemTemplate>
</asp:DataList>

Related

Showing same table to different roles with different options

Currently I just post the same code in different pages for each role, a repeater with a table like this one but each role has different options to do. I tried to place in loginview separator but didn't work, i don't know how to iterate through login view controls and the code just started getting dirtier more than just doing visible = false / true. Is there a more effective way to do this than just making new pages?
<asp:Repeater ID="rptArtigos" runat="server" OnItemCommand="rptArtigos_OnItemCommand" OnItemDataBound="rptArtigos_OnItemDataBound">
<HeaderTemplate>
<table id="tblArtigos" class="table table-bordered dataTable text-center">
<thead class="thead-dark">
<tr>
<th>ID</th>
<th>Ref. Cliente</th>
<th>Ref. Interna</th>
<th>Nome</th>
<th>Estado</th>
<th>Válido Logística</th>
<th>Data Criação</th>
<th></th>
<th></th>
<th id="cell1" runat="server"></th>
<th></th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tbody>
<tr>
<td>
<asp:Label ID="lblIdArtigo" runat="server" Text='<%# Eval("IdArtigo") %>' />
</td>
<td>
<asp:Label ID="lblRefCliente" runat="server" Text='<%# Eval("ReferenciaCliente") %>' />
</td>
<td>
<asp:Label ID="lblRefInterna" runat="server" Text='<%# Eval("ReferenciaInterna") %>' />
</td>
<td>
<asp:LinkButton ID="lkbtnNome" runat="server" Text='<%# Eval("Nome") %>' CommandName="Ver" CommandArgument='<%# Eval("IdArtigo") %>'></asp:LinkButton>
</td>
<td>
<asp:Label ID="lblEstado" runat="server" Text='<%# Eval("EstadoArtigo") %>' />
</td>
<td>
<asp:Label ID="lblAprovadoLogistica" runat="server" Text='<%# Eval("AprovadoLogistica") %>' />
</td>
<td>
<asp:Label ID="lblDataCriacao" runat="server" Text='<%# Eval("DataCriacao") %>' />
</td>
<td class="text-center">
<asp:ImageButton ImageUrl="/Images/Icones/copy.png" Width="25" runat="server" CommandName="Copiar" CommandArgument='<%# Eval("IdArtigo") %>' />
</td>
<td class="text-center">
<asp:ImageButton ImageUrl="/Images/Buttons/edit.png" Width="25" runat="server" CommandName="Editar" CommandArgument='<%# Eval("IdArtigo") %>' />
</td>
<td class="text-center">
<asp:ImageButton ImageUrl="/Images/Buttons/success.png" Width="25" runat="server" OnClientClick="return false;" data-toggle="modal" data-target="#validate" CommandName="Validar" CommandArgument='<%# Eval("IdArtigo") %>' />
</td>
<td class="text-center">
<asp:ImageButton ImageUrl="/Images/Buttons/x-button.png" Width="25" runat="server" CommandName="Rejeitar" CommandArgument='<%# Eval("IdArtigo") %>' />
</td>
</tr>
</tbody>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

ASP.NET and ListView control having LinkButton

I have 10 questions in my sql database. I get them and print them in Link form using LinkButton. Now i want to generate click event of every question separately.
How to generate OnClick event of LinkButton inside ListView. Please help in easy steps.
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="userid" >
<AlternatingItemTemplate>
<tr style="">
<td>
<%-- <asp:Label ID="qtLabel" runat="server" Text='<%# Eval("qt") %>' />
--%>
<h3> <asp:LinkButton CommandArgument='<%# Eval("userid") %>' ID="LinkButton1" runat="server"><%# Eval("qt") %></asp:LinkButton> </h3>
</td>
<td>
<asp:Label ID="useridLabel" runat="server" Text='<%# Eval("userid") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="qtTextBox" runat="server" Text='<%# Bind("qt") %>' />
</td>
<td>
<asp:Label ID="useridLabel1" runat="server" Text='<%# Eval("userid") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</td>
<td>
<asp:TextBox ID="qtTextBox" runat="server" Text='<%# Bind("qt") %>' />
</td>
<td>
<asp:TextBox ID="useridTextBox" runat="server" Text='<%# Bind("userid") %>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="">
<td>
<h3> <asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("userid") %>' runat="server"><%# Eval("qt") %></asp:LinkButton> </h3>
</td>
<td>
<asp:Label ID="useridLabel" runat="server" Text='<%# Eval("userid") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table id="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server">qt</th>
<th runat="server">userid</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style=""></td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="">
<td>
<asp:Label ID="qtLabel" runat="server" Text='<%# Eval("qt") %>' />
</td>
<td>
<asp:Label ID="useridLabel" runat="server" Text='<%# Eval("userid") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>" SelectCommand="SELECT [qt], [userid] FROM [java]"></asp:SqlDataSource>
ASPX:
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1"
DataKeyNames="userid" onitemcommand="ListView1_ItemCommand" >
<AlternatingItemTemplate>
<tr style="">
<td>
<%-- <asp:Label ID="qtLabel" runat="server" Text='<%# Eval("qt") %>' />
--%>
<h3> <asp:LinkButton CommandArgument='<%# Eval("userid") %>' ID="LinkButton1" runat="server"><%# Eval("qt") %></asp:LinkButton> </h3>
</td>
<td>
<asp:Label ID="useridLabel" runat="server" Text='<%# Eval("userid") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="qtTextBox" runat="server" Text='<%# Bind("qt") %>' />
</td>
<td>
<asp:Label ID="useridLabel1" runat="server" Text='<%# Eval("userid") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table id="Table1" runat="server" style="">
<tr>
<td>No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</td>
<td>
<asp:TextBox ID="qtTextBox" runat="server" Text='<%# Bind("qt") %>' />
</td>
<td>
<asp:TextBox ID="useridTextBox" runat="server" Text='<%# Bind("userid") %>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="">
<td>
<h3> <asp:LinkButton ID="LinkButton1" CommandArgument='<%# Eval("userid") %>' runat="server"><%# Eval("qt") %></asp:LinkButton> </h3>
</td>
<td>
<asp:Label ID="useridLabel" runat="server" Text='<%# Eval("userid") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table id="Table2" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table id="itemPlaceholderContainer" runat="server" border="0" style="">
<tr id="Tr2" runat="server" style="">
<th id="Th1" runat="server">qt</th>
<th id="Th2" runat="server">userid</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr3" runat="server">
<td id="Td2" runat="server" style=""></td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="">
<td>
<asp:Label ID="qtLabel" runat="server" Text='<%# Eval("qt") %>' />
</td>
<td>
<asp:Label ID="useridLabel" runat="server" Text='<%# Eval("userid") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>"
SelectCommand="SELECT [qt], [userid] FROM [java]"></asp:SqlDataSource>
Code Behind:
protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e)
{
string userid = e.CommandArgument.ToString();
Response.Write("U:" + userid);
if (userid == "USER_3730")
{
Response.Redirect("bnbnbnbnbn.aspx");
}
if (userid == "USER_b163")
{
Response.Redirect("home.aspx");
}
}

AlternateTemplate is not working for Listview

I modified Listview as per my need,but now is not working, in means, its showing row with different color but repeating same data. And then coming next data, againg its repeating and going on.... Here I am lisitng my code.
for Example,
1
1 (Repeating, Different Color row)
2
2 (Repeating, Different Color row)
3
3 (Repeating, Different Color row)
.
.
.
.
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="uniqueno">
<ItemTemplate>
<tr style="background-color:#DCDCDC;color: #000000;" runat="server">
<td>
<asp:Label ID="policeNumLabel" runat="server" Text='<%# Eval("policeNum") %>' />
</td>
<td>
<asp:Label ID="DFirstNameLabel" runat="server" Text='<%# String.Format("{0} {1} {2}", Eval("DFirstName"),Eval("DMidName"),Eval("DSurName")) %>' />
</td>
<td>
<asp:Label ID="DLicenceNoLabel" runat="server"
Text='<%# Eval("DLicenceNo") %>' />
</td>
<td>
<asp:Label ID="ManufacturerLabel" runat="server"
Text='<%# Eval("Manufacturer") %>' />
</td>
<td>
<asp:Label ID="SerialNumLabel" runat="server" Text='<%# Eval("SerialNum") %>' />
</td>
<td>
<asp:Label ID="ModelLabel" runat="server" Text='<%# Eval("Model") %>' />
</td>
<td>
<asp:Label ID="CalibreLabel" runat="server" Text='<%# Eval("Calibre") %>' />
</td>
<td>
<asp:Label ID="TypeLabel" runat="server" Text='<%# Eval("Type") %>' />
</td>
<td>
<asp:Label ID="ActionLabel" runat="server" Text='<%# Eval("Action") %>' />
</td>
<td>
<asp:Label ID="BarrelLengthLabel" runat="server"
Text='<%# Eval("BarrelLength") %>' />
</td>
<td>
<asp:Label ID="ReasonLabel" runat="server" Text='<%# Eval("Reason") %>' />
</td>
<td>
<asp:Label ID="OtherLabel" runat="server" Text='<%# Eval("Other") %>' />
</td>
<td>
<asp:Label ID="TransferPendingLabel" runat="server" Text='<%# Eval("TransferPending") %>' />
</td>
<td>
<asp:Label ID="OFirstNameLabel" runat="server"
Text='<%# String.Format("{0} {1} {2}", Eval("OFirstName"),Eval("OmidName"),Eval("OSurName")) %>' />
</td>
<td>
<asp:Label ID="O_LicenceNoLabel" runat="server"
Text='<%# Eval("O_LicenceNo") %>' />
</td>
<td>
<asp:Label ID="DateAcqLabel" runat="server" Text='<%# Eval("DateAcq") %>' />
</td>
<td>
<asp:Label ID="Dis_FirstnameLabel" runat="server"
Text='<%# String.Format("{0} {1} {2}",Eval("Dis_Firstname"),Eval("Dis_Midname"),Eval("Dis_Surname")) %>' />
</td>
<td>
<asp:Label ID="Dis_LicenceNoLabel" runat="server"
Text='<%# Eval("Dis_LicenceNo") %>' />
</td>
<td>
<asp:Label ID="Dis_DisposaldateLabe" runat="server"
Text='<%# Eval("Dis_Disposaldate") %>' />
</td>
<td>
<asp:Label ID="Dis_CommentLabel" runat="server"
Text='<%# Eval("Dis_Comment") %>' />
</td>
<td>
<asp:Label ID="PermittoAcqNoLabel" runat="server" Text='<%# Eval("PermittoAcqNo") %>' />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr id="Tr1" style="background-color:#DCDCDC;color: #000000;" runat="server">
<td>
<asp:Label ID="policeNumLabel" runat="server" Text='<%# Eval("policeNum") %>' />
</td>
<td>
<asp:Label ID="DFirstNameLabel" runat="server" Text='<%# String.Format("{0} {1} {2}", Eval("DFirstName"),Eval("DMidName"),Eval("DSurName")) %>' />
</td>
<td>
<asp:Label ID="DLicenceNoLabel" runat="server"
Text='<%# Eval("DLicenceNo") %>' />
</td>
<td>
<asp:Label ID="ManufacturerLabel" runat="server"
Text='<%# Eval("Manufacturer") %>' />
</td>
<td>
<asp:Label ID="SerialNumLabel" runat="server" Text='<%# Eval("SerialNum") %>' />
</td>
<td>
<asp:Label ID="ModelLabel" runat="server" Text='<%# Eval("Model") %>' />
</td>
<td>
<asp:Label ID="CalibreLabel" runat="server" Text='<%# Eval("Calibre") %>' />
</td>
<td>
<asp:Label ID="TypeLabel" runat="server" Text='<%# Eval("Type") %>' />
</td>
<td>
<asp:Label ID="ActionLabel" runat="server" Text='<%# Eval("Action") %>' />
</td>
<td>
<asp:Label ID="BarrelLengthLabel" runat="server"
Text='<%# Eval("BarrelLength") %>' />
</td>
<td>
<asp:Label ID="ReasonLabel" runat="server" Text='<%# Eval("Reason") %>' />
</td>
<td>
<asp:Label ID="OtherLabel" runat="server" Text='<%# Eval("Other") %>' />
</td>
<td>
<asp:Label ID="TransferPendingLabel" runat="server" Text='<%# Eval("TransferPending") %>' />
</td>
<td>
<asp:Label ID="OFirstNameLabel" runat="server"
Text='<%# String.Format("{0} {1} {2}", Eval("OFirstName"),Eval("OmidName"),Eval("OSurName")) %>' />
</td>
<td>
<asp:Label ID="O_LicenceNoLabel" runat="server"
Text='<%# Eval("O_LicenceNo") %>' />
</td>
<td>
<asp:Label ID="DateAcqLabel" runat="server" Text='<%# Eval("DateAcq") %>' />
</td>
<td>
<asp:Label ID="Dis_FirstnameLabel" runat="server"
Text='<%# String.Format("{0} {1} {2}",Eval("Dis_Firstname"),Eval("Dis_Midname"),Eval("Dis_Surname")) %>' />
</td>
<td>
<asp:Label ID="Dis_LicenceNoLabel" runat="server"
Text='<%# Eval("Dis_LicenceNo") %>' />
</td>
<td>
<asp:Label ID="Dis_DisposaldateLabe" runat="server"
Text='<%# Eval("Dis_Disposaldate") %>' />
</td>
<td>
<asp:Label ID="Dis_CommentLabel" runat="server"
Text='<%# Eval("Dis_Comment") %>' />
</td>
<td>
<asp:Label ID="PermittoAcqNoLabel" runat="server" Text='<%# Eval("PermittoAcqNo") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EmptyDataTemplate>
<table runat="server"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
<tr>
<td>
No data found</td>
</tr>
</table>
</EmptyDataTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="1"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr runat="server" >
<th colspan="3" runat="server">Dealer Info </th>
<th colspan="7" runat="server">Firearm Details </th>
<th colspan="3" runat="server">Reason </th>
<th colspan="3" runat="server">Acquisition Details </th>
<th colspan="5" runat="server">Disposal Details </th>
</tr>
<tr runat="server" style="background-color:#DCDCDC;color: #000000;">
<th runat="server">Number</th>
<th runat="server">Name</th>
<th runat="server">Licence #</th>
<th runat="server">Manufacturer</th>
<th runat="server">Serial #</th>
<th runat="server">Model</th>
<th runat="server">Calibre</th>
<th runat="server">Type</th>
<th runat="server">Action</th>
<th runat="server">Barrel Length</th>
<th runat="server">Reason</th>
<th runat="server">Other</th>
<th runat="server">Transfer Pending</th>
<th runat="server">Name</th>
<th runat="server">Licence #</th>
<th runat="server">Date of Acquired</th>
<th runat="server">Name</th>
<th runat="server">Licence #</th>
<th runat="server">Date of Disposal</th>
<th runat="server">Comment</th>
<th runat="server">Permit to Acquire No</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server"
style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
<td>
<asp:Label ID="policeNumLabel" runat="server" Text='<%# Eval("policeNum") %>' />
</td>
<td>
<asp:Label ID="DFirstNameLabel" runat="server"
Text='<%# Eval("DFirstName") %>' />
</td>
<td>
<asp:Label ID="DMidNameLabel" runat="server" Text='<%# Eval("DMidName") %>' />
</td>
<td>
<asp:Label ID="DSurNameLabel" runat="server" Text='<%# Eval("DSurName") %>' />
</td>
<td>
<asp:Label ID="DLicenceNoLabel" runat="server"
Text='<%# Eval("DLicenceNo") %>' />
</td>
<td>
<asp:Label ID="Dis_DisposaldateLabel" runat="server"
Text='<%# Eval("Dis_Disposaldate") %>' />
</td>
<td>
<asp:Label ID="SerialNumLabel" runat="server" Text='<%# Eval("SerialNum") %>' />
</td>
<td>
<asp:Label ID="CalibreLabel" runat="server" Text='<%# Eval("Calibre") %>' />
</td>
<td>
<asp:Label ID="BarrelLengthLabel" runat="server"
Text='<%# Eval("BarrelLength") %>' />
</td>
<td>
<asp:Label ID="ManufacturerLabel" runat="server"
Text='<%# Eval("Manufacturer") %>' />
</td>
<td>
<asp:Label ID="OtherLabel" runat="server" Text='<%# Eval("Other") %>' />
</td>
<td>
<asp:Label ID="ModelLabel" runat="server" Text='<%# Eval("Model") %>' />
</td>
<td>
<asp:Label ID="TypeLabel" runat="server" Text='<%# Eval("Type") %>' />
</td>
<td>
<asp:Label ID="ActionLabel" runat="server" Text='<%# Eval("Action") %>' />
</td>
<td>
<asp:Label ID="TransferPendingLabel" runat="server"
Text='<%# Eval("TransferPending") %>' />
</td>
<td>
<asp:Label ID="DateAcqLabel" runat="server" Text='<%# Eval("DateAcq") %>' />
</td>
<td>
<asp:Label ID="OFirstNameLabel" runat="server"
Text='<%# Eval("OFirstName") %>' />
</td>
<td>
<asp:Label ID="OmidNameLabel" runat="server" Text='<%# Eval("OmidName") %>' />
</td>
<td>
<asp:Label ID="OSurNameLabel" runat="server" Text='<%# Eval("OSurName") %>' />
</td>
<td>
<asp:Label ID="O_LicenceNoLabel" runat="server"
Text='<%# Eval("O_LicenceNo") %>' />
</td>
<td>
<asp:Label ID="DNoLabel" runat="server" Text='<%# Eval("DNo") %>' />
</td>
<td>
<asp:Label ID="StreetLabel" runat="server" Text='<%# Eval("Street") %>' />
</td>
<td>
<asp:Label ID="column1Label" runat="server" Text='<%# Eval("column1") %>' />
</td>
<td>
<asp:Label ID="StateLabel" runat="server" Text='<%# Eval("State") %>' />
</td>
<td>
<asp:Label ID="PostCodeLabel" runat="server" Text='<%# Eval("PostCode") %>' />
</td>
<td>
<asp:Label ID="PermittoAcqNoLabel" runat="server"
Text='<%# Eval("PermittoAcqNo") %>' />
</td>
<td>
<asp:Label ID="Dis_FirstnameLabel" runat="server"
Text='<%# Eval("Dis_Firstname") %>' />
</td>
<td>
<asp:Label ID="Dis_MidnameLabel" runat="server"
Text='<%# Eval("Dis_Midname") %>' />
</td>
<td>
<asp:Label ID="Dis_SurnameLabel" runat="server"
Text='<%# Eval("Dis_Surname") %>' />
</td>
<td>
<asp:Label ID="Dis_LicenceNoLabel" runat="server"
Text='<%# Eval("Dis_LicenceNo") %>' />
</td>
<td>
<asp:Label ID="Dis_DnoLabel" runat="server" Text='<%# Eval("Dis_Dno") %>' />
</td>
<td>
<asp:Label ID="Dis_StreetLabel" runat="server"
Text='<%# Eval("Dis_Street") %>' />
</td>
<td>
<asp:Label ID="column2Label" runat="server" Text='<%# Eval("column2") %>' />
</td>
<td>
<asp:Label ID="Dis_stateLabel" runat="server" Text='<%# Eval("Dis_state") %>' />
</td>
<td>
<asp:Label ID="Dis_postcodeLabel" runat="server"
Text='<%# Eval("Dis_postcode") %>' />
</td>
<td>
<asp:Label ID="Dis_CommentLabel" runat="server"
Text='<%# Eval("Dis_Comment") %>' />
</td>
<td>
<asp:Label ID="ReasonLabel" runat="server" Text='<%# Eval("Reason") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
There was no fault with code....
After having lots of experiment, I realise that there something wrong with my Database, and that's what happened, there was duplicate existed which were removed and now listview is work fine.

File Uploader not working wnen used in ajax tab container with update panel

I am using ajax tab container with update panel and file uploader
fileuploaderId.HasFille always blank.
Here is my html code
<cc1:TabPanel ID="tour" runat="server">
<HeaderTemplate>
<span class="label_Tag_big">भ्रमण (Tours)</span></HeaderTemplate>
<ContentTemplate>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<center class="control_bg">
<table width="75%" cellspacing="1">
<tr>
<td style="background-color: #996666">
<table width="100%" align="center" cellpadding="0" cellspacing="1">
<tr class="form_heading">
<td colspan="2">
<asp:Label ID="lbl" runat="server" Text="भ्रमण (Tours)"></asp:Label>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
विभागाध्‍यक्ष / अधिकारी का पद नाम
</td>
<td>
designation location, department
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
<asp:Label ID="lblCurrentTT" runat="server"></asp:Label>
का लक्ष्‍य
</td>
<td>
<asp:Label ID="lblTargetT" runat="server"></asp:Label>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
<asp:Label ID="lblCurrentTA" runat="server"></asp:Label>
की लक्ष्‍य प्राप्ति
</td>
<td>
<asp:Label ID="lblAchivedT" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="form_sub_heading" colspan="2" align="left">
भ्रमण का विवरण (Tours details)
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td width="45%">
दौरे का स्थान
</td>
<td width="55%">
<table width="100%" cellpadding="3" cellspacing="0">
<tr>
<td width="50%">
<asp:DropDownList ID="ddlLocLevel" runat="server" OnSelectedIndexChanged="ddlLocLevel_SelectedIndexChanged"
AutoPostBack="True" Width="200px" />
<asp:RequiredFieldValidator ID="rfqLocLevel" runat="server" InitialValue="0" ControlToValidate="ddlLocLevel"
Display="None" ErrorMessage="दौरे का स्थान चुनें " ValidationGroup="tour"></asp:RequiredFieldValidator>
</td>
<td width="50%">
<asp:DropDownList ID="ddlLocation" runat="server" OnSelectedIndexChanged="ddlLocation_SelectedIndexChanged"
AutoPostBack="True" Width="200px">
<asp:ListItem Text="-- चुनें --" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfqLocation" runat="server" InitialValue="0" ControlToValidate="ddlLocation"
Display="None" ErrorMessage="-- चुनें --" ValidationGroup="tour" Enabled="false"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
<asp:DropDownList ID="ddlSubDistrict" runat="server" OnSelectedIndexChanged="ddlSubDistrict_SelectedIndexChanged"
AutoPostBack="True" Width="200px">
<asp:ListItem Text="-- तहसील चुनें --" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfqddlSubDistrict" runat="server" InitialValue="0"
ControlToValidate="ddlSubDistrict" Display="None" ErrorMessage="-- चुनें --"
ValidationGroup="tour" Enabled="false"></asp:RequiredFieldValidator>
</td>
<td>
<asp:DropDownList ID="ddlPoliceStation" runat="server" Width="200px">
<asp:ListItem Text="-- पुलिस थाना चुनें --" Value="0"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfqddlPoliceStation" runat="server" InitialValue="0"
ControlToValidate="ddlPoliceStation" Display="None" ErrorMessage="-- पुलिस थाना चुनें --"
ValidationGroup="tour" Enabled="false"></asp:RequiredFieldValidator>
</td>
</tr>
</table>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
<asp:Label ID="lblTourStartDate" runat="server" Text="दौरे की तिथि "></asp:Label>
</td>
<td>
<asp:TextBox ID="txtTourStartDate" runat="server" Width="25%" CssClass="date" onkeypress="return false;"
onPaste="return false;"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtTourStartDate"
Format="dd/MM/yyyy">
</cc1:CalendarExtender>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTourStartDate"
ErrorMessage="दौरे की आरम्भिक तिथि डाले" ValidationGroup="tour" Display="None"></asp:RequiredFieldValidator>
से
<asp:TextBox ID="txtTourEndDate" runat="server" Width="25%" onkeypress="return false;"
onPaste="return false;"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="txtTourEndDate"
Format="dd/MM/yyyy">
</cc1:CalendarExtender>
तक
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtTourEndDate"
ErrorMessage="दौरे की समाप्ति तिथि डाले" ValidationGroup="tour" Display="None"></asp:RequiredFieldValidator>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
दौरे के दौरान निरीक्षण किया गया ?
</td>
<td>
<asp:RadioButtonList ID="rdbtnInsp" runat="server" RepeatDirection="Horizontal" AutoPostBack="true"
OnSelectedIndexChanged="rdbtnInsp_SelectedIndexChanged">
<asp:ListItem Text="नही" Value="0"></asp:ListItem>
<asp:ListItem Text="हाँ" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
निरीक्षण नही किये जाने की स्थिति मे टिप्पणी
</td>
<td>
<asp:TextBox ID="txtConIns" runat="server" TextMode="MultiLine" MaxLength="4000"
Enabled="false" Rows="3" Width="97%"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfqConIns" runat="server" ControlToValidate="txtConIns"
ValidationGroup="tour" ErrorMessage="निरीक्षण नही किये जाने की स्थिति मे टिप्पणी डाले "
Enabled="false" Display="None">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
दौरे के दौरान रात्री विश्राम किया गया ?
</td>
<td>
<asp:RadioButtonList ID="rdbtnNHault" runat="server" RepeatDirection="Horizontal"
AutoPostBack="true" OnSelectedIndexChanged="rdbtnNHault_SelectedIndexChanged">
<asp:ListItem Text="नही" Value="0"></asp:ListItem>
<asp:ListItem Text="हाँ" Value="1"></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
रात्री विश्राम नही किये जाने की स्थिति मे टिप्पणी
</td>
<td>
<asp:TextBox ID="txtConNHault" runat="server" TextMode="MultiLine" MaxLength="4000"
Enabled="false" Rows="3" Width="97%"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfqConNHault" runat="server" ControlToValidate="txtConNHault"
Display="None" ValidationGroup="tour" ErrorMessage="रात्री विश्राम नही किये जाने की स्थिति मे टिप्पणी डाले "
Enabled="false">
</asp:RequiredFieldValidator>
<asp:ValidationSummary ID="vsTour" runat="server" ShowSummary="False" ShowMessageBox="true"
ValidationGroup="tour" />
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td>
<asp:Label ID="Label8" runat="server" Text="संलग्न निरीक्षण रिपोर्ट "></asp:Label>
</td>
<td>
<asp:FileUpload ID="fuTourReport" runat="server" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ErrorMessage="Only pdf file is allowed!"
ValidationExpression="^.+(.pdf|.PDF)$" ControlToValidate="fuTourReport" Display="None"
ValidationGroup="nhalt"> </asp:RegularExpressionValidator>
</td>
</tr>
<tr class="bgColor" align="left" valign="top">
<td colspan="2" align="center">
<asp:Button ID="btnSaveTour" runat="server" Text="Submit" ValidationGroup="tour"
OnClick="btnSaveTour_Click" CssClass="savetour" />
<asp:Button ID="btnCancelTour" runat="server" Text="Cancel" CausesValidation="False" />
</td>
</tr>
</table>
</td>
</tr>
</table>
<center style="padding-top: 5px">
<asp:GridView ID="grdTours" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataKeyNames="tourId" Width="100%" OnPageIndexChanging="grdTours_PageIndexChanging"
OnRowCommand="grdTours_RowCommand">
<Columns>
<asp:BoundField DataField="Location_NameH" HeaderText="दौरे का स्थान " />
<asp:BoundField DataField="tourStartDate" HeaderText="आरम्‍भिक तिथि" DataFormatString="{0:dd/MM/yyyy}" />
<asp:BoundField DataField="tourEndDate" HeaderText="समाप्‍ति की तिथि" DataFormatString="{0:dd/MM/yyyy}" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkinsdetail" runat="server" Text="Detail" CommandName="insdetail"
CommandArgument='<%#Eval("tourId")%>'></asp:LinkButton></ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</center>
</center>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
I have already tried this
<Triggers>
<asp:PostBackTrigger ControlID="clickButton" />
</Triggers>
and
protected void Page_Init(object sender, EventArgs e)
{
PostBackTrigger trig = new PostBackTrigger();
trig.ControlID = btnSaveTour.UniqueID;
UpdatePanel1.Triggers.Add(trig);
}
but no luck ....
Unfortunately, the FileUpload control doesn't work inside an UpdatePanel
You don't have many options really other than removing the UpdatePanel or looking at working around it by using something like the AsyncFileUpload control
See this answer for some more detail
Dave

how to make a new button in ListView?

I need to make an image button in the layout template of ListView,
when i click on the button it should open the insert template so i can insert a new record
here is my ListView:
<asp:ListView ID="LVCategories" runat="server" DataKeyNames="CatID" DataSourceID="CategoriesDS" EnableModelValidation="True">
<AlternatingItemTemplate>
<tr style="">
<td>
<asp:Label ID="CatIDLabel" runat="server" Text='<%# Eval("CatID") %>' />
</td>
<td>
<asp:Label ID="CatTitleLabel" runat="server" Text='<%# Eval("CatTitle") %>' />
</td>
<td>
<asp:Label ID="CatDescriptionLabel" runat="server" Text='<%# Eval("CatDescription") %>' />
</td>
<td>
<asp:Label ID="CatTitleArLabel" runat="server" Text='<%# Eval("CatTitleAr") %>' />
</td>
<td>
<asp:Label ID="CatDescriptionArLabel" runat="server" Text='<%# Eval("CatDescriptionAr") %>' />
</td>
<td>
<asp:Label ID="PictureIDLabel" runat="server" Text='<%# Eval("PictureID") %>' />
</td>
<td>
<asp:CheckBox ID="PublishedCheckBox" runat="server" Checked='<%# Eval("Published") %>' Enabled="false" />
</td>
<td>
<asp:Label ID="DisplayOrderLabel" runat="server" Text='<%# Eval("DisplayOrder") %>' />
</td>
<td>
<asp:Label ID="CreatedOnLabel" runat="server" Text='<%# Eval("CreatedOn") %>' />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:Label ID="CatIDLabel1" runat="server" Text='<%# Eval("CatID") %>' />
</td>
<td>
<asp:TextBox ID="CatTitleTextBox" runat="server" Text='<%# Bind("CatTitle") %>' />
</td>
<td>
<asp:TextBox ID="CatDescriptionTextBox" runat="server" Text='<%# Bind("CatDescription") %>' />
</td>
<td>
<asp:TextBox ID="CatTitleArTextBox" runat="server" ext='<%# Bind("CatTitleAr") %>' />
</td>
<td>
<asp:TextBox ID="CatDescriptionArTextBox" runat="server" Text='<%# Bind("CatDescriptionAr") %>' />
</td>
<td>
<asp:TextBox ID="PictureIDTextBox" runat="server" Text='<%# Bind("PictureID") %>' />
</td>
<td>
<asp:CheckBox ID="PublishedCheckBox" runat="server" Checked='<%# Bind("Published") %>' />
</td>
<td>
<asp:TextBox ID="DisplayOrderTextBox" runat="server" Text='<%# Bind("DisplayOrder") %>' />
</td>
<td>
<asp:TextBox ID="CreatedOnTextBox" runat="server" Text='<%# Bind("CreatedOn") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>
No data was returned.
</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</td>
<td>
<asp:TextBox ID="CatIDTextBox" runat="server" Text='<%# Bind("CatID") %>' />
</td>
<td>
<asp:TextBox ID="CatTitleTextBox" runat="server" Text='<%# Bind("CatTitle") %>' />
</td>
<td>
<asp:TextBox ID="CatDescriptionTextBox" runat="server" Text='<%# Bind("CatDescription") %>' />
</td>
<td>
<asp:TextBox ID="CatTitleArTextBox" runat="server" Text='<%# Bind("CatTitleAr") %>' />
</td>
<td>
<asp:TextBox ID="CatDescriptionArTextBox" runat="server" Text='<%# Bind("CatDescriptionAr") %>' />
</td>
<td>
<asp:TextBox ID="PictureIDTextBox" runat="server" Text='<%# Bind("PictureID") %>' />
</td>
<td>
<asp:CheckBox ID="PublishedCheckBox" runat="server" Checked='<%# Bind("Published") %>' />
</td>
<td>
<asp:TextBox ID="DisplayOrderTextBox" runat="server" Text='<%# Bind("DisplayOrder") %>' />
</td>
<td>
<asp:TextBox ID="CreatedOnTextBox" runat="server" Text='<%# Bind("CreatedOn") %>' />
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:Label ID="CatIDLabel" runat="server" Text='<%# Eval("CatID") %>' />
</td>
<td>
<asp:Label ID="CatTitleLabel" runat="server" Text='<%# Eval("CatTitle") %>' />
</td>
<td>
<asp:Label ID="CatDescriptionLabel" runat="server" Text='<%# Eval("CatDescription") %>' />
</td>
<td>
<asp:Label ID="CatTitleArLabel" runat="server" Text='<%# Eval("CatTitleAr") %>' />
</td>
<td>
<asp:Label ID="CatDescriptionArLabel" runat="server" Text='<%# Eval("CatDescriptionAr") %>' />
</td>
<td>
<asp:Label ID="PictureIDLabel" runat="server" Text='<%# Eval("PictureID") %>' />
</td>
<td>
<asp:CheckBox ID="PublishedCheckBox" runat="server" Checked='<%# Eval("Published") %>' Enabled="false" />
</td>
<td>
<asp:Label ID="DisplayOrderLabel" runat="server" Text='<%# Eval("DisplayOrder") %>' />
</td>
<td>
<asp:Label ID="CreatedOnLabel" runat="server" Text='<%# Eval("CreatedOn") %>' />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server">
<asp:ImageButton ID="btnNew" runat="server" CommandName="New" />
<%--<asp:ImageButton ID="NewCatbtn" runat="server" CommandName="Insert" ImageUrl="~/ADMIN/themes/Img/New.png" AlternateText="Click Here To Add New" OnClick="OpenTheInsertTemplates"/>--%>
</th>
<th runat="server">CatTitle</th>
<th runat="server">CatDescription</th>
<th runat="server">CatTitleAr</th>
<th runat="server">atDescriptionAr</th>
<th runat="server">PictureID</th>
<th runat="server">Published</th>
<th runat="server">DisplayOrder</th>
<th runat="server">CreatedOn</th>
</tr>
<tr ID="itemPlaceholder" runat="server"></tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style=""></td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="">
<td>
<asp:Label ID="CatIDLabel" runat="server" Text='<%# Eval("CatID") %>' />
</td>
<td>
<asp:Label ID="CatTitleLabel" runat="server" Text='<%# Eval("CatTitle") %>' />
</td>
<td>
<asp:Label ID="CatDescriptionLabel" runat="server"
Text='<%# Eval("CatDescription") %>' />
</td>
<td>
<asp:Label ID="CatTitleArLabel" runat="server"
Text='<%# Eval("CatTitleAr") %>' />
</td>
<td>
<asp:Label ID="CatDescriptionArLabel" runat="server"
Text='<%# Eval("CatDescriptionAr") %>' />
</td>
<td>
<asp:Label ID="PictureIDLabel" runat="server" Text='<%# Eval("PictureID") %>' />
</td>
<td>
<asp:CheckBox ID="PublishedCheckBox" runat="server"
Checked='<%# Eval("Published") %>' Enabled="false" />
</td>
<td>
<asp:Label ID="DisplayOrderLabel" runat="server"
Text='<%# Eval("DisplayOrder") %>' />
</td>
<td>
<asp:Label ID="CreatedOnLabel" runat="server" Text='<%# Eval("CreatedOn") %>' />
</td>
</tr>
</SelectedItemTemplate>
<asp:Button runat="server" ID="cmdInsert" CommandName="Insert" Text="Insert" />
Protected Sub ListView1_ItemInserting (ByVal sender As Object, ByVal e as ListViewEditEventArgs)
' ... '
End Sub
this example has been solved like this :
ASPX file:
<th runat="server">
<asp:ImageButton ID="ImageButton1" runat="server" Text="new" CommandName="new" ImageUrl="~/ADMIN/themes/Img/DeleteBtn.png" />
</th>
the VB.net Code:
Sub deletedd(ByVal sender As Object, ByVal e As ListViewCommandEventArgs) Handles ListView1.ItemCommand
Try
If e.CommandName.Equals("Delete") Then
'this to take a value from any control
Dim Idlabel As Label = e.Item.FindControl("ImageIDLabel")
Session("ID") = Idlabel.Text()
End If
If e.CommandName.Equals("new") Then
'Other code
ListView1.InsertItemPosition = InsertItemPosition.FirstItem
End If
If e.CommandName.Equals("Cancel") Then
'Other code
ListView1.InsertItemPosition = InsertItemPosition.None
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Resources