Click here to Skip to main content
16,022,798 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

1) I need to get the hyperlink text value( <code>Text='&lt;%#Eval(&quot;file_name&quot;)%&gt;'</code> ) when I will click on hyperlink.

2) I need to get the link button command name when i will click on Linkbutton.

Below is my Datalist code.
<pre lang="HTML"> &lt;asp:DataList ID=&quot;datamum&quot; runat=&quot;server&quot; DataKeyField=&quot;Policy_id&quot;
Font-Bold=&quot;False&quot; Font-Italic=&quot;False&quot; Font-Overline=&quot;False&quot;
Font-Strikeout=&quot;False&quot; Font-Underline=&quot;False&quot; HorizontalAlign=&quot;Left&quot;
onitemdatabound=&quot;datamum_ItemDataBound&quot; Font-Size=&quot;Smaller&quot; onitemcommand=&quot;datamum_ItemCommand&quot;&gt;

&lt;ItemTemplate&gt;

&lt;asp:Label ID=&quot;lblid&quot; runat=&quot;server&quot; Text='&lt;%# Eval(&quot;Policy_id&quot;)%&gt;' Visible=&quot;false&quot;&gt;&lt;/asp:Label&gt;
&lt;asp:Label ID=&quot;lbl&quot; runat=&quot;server&quot; Text=&quot;*&quot; ForeColor=&quot;Brown&quot;&gt;&lt;/asp:Label&gt;
&lt;asp:Hyperlink ID=&quot;hyfile&quot; runat=&quot;server&quot; Text='&lt;%#Eval(&quot;file_name&quot;)%&gt;' NavigateUrl=&quot;#&quot; &gt;&lt;/asp:Hyperlink&gt;
&lt;asp:Panel ID=&quot;panid&quot; runat=&quot;server&quot; Style=&quot;display:none;&quot;&gt;
&lt;asp:DataList ID=&quot;Datasub&quot; runat=&quot;server&quot;&gt;
&lt;ItemTemplate&gt;
&lt;asp:Label ID=&quot;lbl&quot; runat=&quot;server&quot; Text=&quot;*&quot; ForeColor=&quot;Blue&quot; &gt;&lt;/asp:Label&gt;
&lt;asp:LinkButton ID=&quot;lnkid&quot; runat=&quot;server&quot; Text='&lt;%#Eval(&quot;file_name&quot;)%&gt;' CommandName=&quot;Display&quot;&gt;&lt;/asp:LinkButton&gt;
&lt;/ItemTemplate&gt;
&lt;/asp:DataList&gt;
&lt;/asp:Panel&gt;
&lt;/ItemTemplate&gt;

&lt;/asp:DataList&gt;
</pre>
Thanks in Advance

Sucharitha
Posted
Updated 28-Dec-11 18:06pm
v2

1 solution

try this on Item_Command Event

C#
LinkButton lnkbtn = (LinkButton)(e.CommandSource);
string lnkbtnText = lnkbtn.Text;

string CommandNAme = e.CommandName; // or lnkbtn.CommandName


hope this helps..
 
Share this answer
 
v2
Comments
RagSuchi 22-Dec-11 5:14am    
Hi Karthik,
Thanks for your reply,
Its working, but i need the datakey value of 2nd datalist.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900