Friday, June 17, 2011

GridView:- LinkButtons_AnchorTag_HyperLinks



 <ItemTemplate> 
  <asp:LinkButton ID="lnkedit" runat="server" CommandName="Edit" CommandArgument='<%#Eval("ClientID")  + "," + Eval("AssetID") + "," + Eval("strStartDate") + "," + Eval("strEnddate") + "," +  Eval("AssignedTo") %>'

Style='<%#Eval("IsCompleted").ToString().Equals("1")?"visibility:hidden": "visibility:show"%>'>
         <img src="../images/icon_edit.gif" style="border:0;" title="Edit Schedule" />


 </asp:LinkButton>
 </ItemTemplate>
-------------------------------------------------------------------------------
 <ItemTemplate>
   <asp:Label ID="lblStatus" runat="server" 
Text='<%#Convert.ToString(Eval("isActive")).ToLower()=="true"?"Activated":"DeActivated" %>'>
 </asp:Label>
</ItemTemplate>


--------------------------------------------------------
<ItemTemplate>
<asp:LinkButton ID="lnkbtnIsactive" runat="server"
OnClick="change_status"
CommandArgument='<%#Eval("ID")+","+Eval("ProjectID") %>'
ToolTip='<%#Eval("UserName")%>'
Text='<%#get(Convert.ToBoolean((Eval("IsActive"))))%>'
></asp:LinkButton>
</ItemTemplate>
//(can also use <img src> in linkbutton)

lnk = ((LinkButton)(sender));
string[] array = lnk.CommandArgument.ToString().Split(',');
prjID = Convert.ToInt32(array[1].ToString());
Int32 bid = Convert.ToInt32(array[0].ToString());

****************************************
<ItemTemplate>
<asp:LinkButton ID="lnkview" runat="server" CommandName="viewProject"
CommandArgument='<%#Eval("ID") %>'
CssClass="tahomatext"><img src="../images/icon_details.png" style="border:0;" alt="Bidding Details" title="Bidding Details" /></asp:LinkButton>
</ItemTemplate>
--------------------------------------

protected void grdProject_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.ToString() == "viewProject")
{
uid = Convert.ToInt32(e.CommandArgument.ToString());
Response.Redirect("BidDetails.aspx?pid=" + uid);
}
}


************************************************
<ItemTemplate>
<a href="addFeedBackLister.aspx?pid=<%#Eval("ID") %>&cid=<%#Eval("ContractorID") %>"
title="Give feedback"
class='<%#visibleBtn(Convert.ToInt64(Eval("ID")))%>'>

<img src="../images/reviewadd.png" height="25" width="25" border="0px" />

</a>
</ItemTemplate>

-----------------------------------
public String visibleBtn(Int64 pid)
{
Hashtable ht = new Hashtable();
ht.Clear();
ht.Add("@pid", pid);

Int32 result = NSBuilder.DataAccess.ExecuteNonQueryWithReturnParameter("Usp_AlreadyRated", ht);
if (result == 1)
{
return "visible";
}
else
{
return "hide";
}
}

********************************************
Note:-- no runat attribute in anchor tag

<a href='viewZipCode.aspx?s=<%#Eval("TState")%>&c=<%#Eval("TCounty") %>'

onclick="return hs.htmlExpand(this, { objectType: 'iframe' } )"> View Zip </a>

*******************************************

<ItemTemplate>

<a href="UpdateFranchiseeProfile.aspx?uid='<%#Eval("FranchID") %>'&mail=<%#Eval ("Email") %>"><%#Eval("UserName") %>
</a>

</ItemTemplate>
********************************************


<ItemTemplate>
<asp:LinkButton ID="lnkApprove" CommandName="Approve"
CommandArgument='<%#Eval("RID") %>'
CssClass='<%#visibleBtn(Convert.ToInt64(Eval("RID"))) %>'
runat="server">Approved</asp:LinkButton>
</ItemTemplate>
******************************************

<ItemTemplate>
<asp:LinkButton ID="lnkbtnIsactive" runat="server" OnClick="change_status" ToolTip='<%#Eval("UserName")%>'
Text='<%#get(Convert.ToBoolean((Eval("IsActive"))))%>' CssClass="tahomatext"></asp:LinkButton>
</ItemTemplate>
################################


<%-- NO runat tag in <anchor> --%>
<ItemTemplate>
<a href="ProductDetails.aspx?pid=<%#Eval("ID")%>">
<img src="Images/<%#Eval("Image") %>" alt="image" />
</a>
</ItemTemplate>



<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<a href="UpdateSubAdmin.aspx?ud=<%#Eval("UserID") %>&un=<%#Eval("UserName") %>">
<img src="../images/Edit.png" style="border: 0;" alt="Edit Sub Admin" title="Edit Sub Admin" />
</a>
</ItemTemplate>
</asp:TemplateField>

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More