In asp.net gridview, here we have to hide all extra characters and display only limited number of characters by clicking on gridview column with the help of java script function placed on anchor tag in asp.net gridview column of ItemTemplate.
Source Code :
Source Code :
<asp:GridView ID="gvRpts" runat="server" AutoGenerateColumns="False
Width="100%" >
<Columns>
<asp:BoundField DataField="Date"
HeaderText="Date"
></asp:BoundField>
<asp:TemplateField HeaderText="Particulars">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"
Text='<%# Bind("Particulars") %>'></asp:TextBox> </EditItemTemplate>
<ItemTemplate>
<a id="anchrID" onclick="javascript:showExtraChars('<%# Eval("Particulars") %>')" >
<asp:Label ID="Label2" runat="server"
Text='<%#Eval("Particulars").ToString().Length
<= 25 ? Eval("Particulars") : (Eval("Particulars") as
string).Substring(0,26)+"..." %>'>
</asp:Label></a>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Javascript Code :
<script language="javascript" type="text/javascript">
function showExtraChars
(reason) {
if (reason == null ||
reason == "")
alert('Empty data… ');
else
alert(reason);
}
</script>
Result :
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-119431924-1');
No comments:
Post a Comment