Click here to Skip to main content
15,886,567 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
i have element
<a href='ViewTeacherEmail.aspx?Back=2&ID=<%# DataBinder.Eval(Container.DataItem, "ID") %>  
in my datagrid.Iwant to change " href value to "
ViewParentEmail.aspx
" when
DataBinder.Eval(Container.DataItem, "Type")=2 
and to"
ViewTeacherEmail.aspx
" when
DataBinder.Eval(Container.DataItem, "Type")=1

plz help
Posted
Updated 3-Jan-13 18:24pm
v2

1 solution

I solve its by adding a literal to grid view .I dont know whether its a good solution.Any way you got desired output :)
XML
protected void TaalebDGView_OnItemDataBound(object sender, DataGridItemEventArgs e)
   {
       if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
       {
           e.Item.Attributes.Add("onmouseover", "this.className='tr_mouseover'");
           e.Item.Attributes.Add("onmouseout", "this.className=''");
           Literal ltlhrf = (Literal)e.Item.FindControl("hrf");
           if (DataBinder.Eval(e.Item.DataItem, "EmailType").ToString() == "1")
           {
               ltlhrf.Text = "<a href='ViewTeacherEmail.aspx?Back=2&ID=" + DataBinder.Eval(e.Item.DataItem, "ID").ToString() + "'><img src=\"../../css/layout/site/tables/icon_search.png\" width=\"16\" height=\"16\"  style=\"border:0;\" alt=\"View\" title=\"View\"  /></a>   ";
           }
           else
           {
               ltlhrf.Text = "<a href='ViewReceivedBox.aspx.aspx?Back=2&ID=" + DataBinder.Eval(e.Item.DataItem, "ID").ToString() + "'><img src=\"../../css/layout/site/tables/icon_search.png\" width=\"16\" height=\"16\"  style=\"border:0;\" alt=\"View\" title=\"View\"  /></a>   ";

           }


}
 
Share this answer
 

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