Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all,

How to check 2 conditions in the template field, GridView, Asp.Net. Depending upon that the image button should be displayed in the gridview

Help pl

Regards,
Praveen
Posted

U can use RowDataBound Event in gridview
Try n Understand the following example:


protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string status = DataBinder.Eval(e.Row.DataItem, "Status").ToString();
if (status.Trim() == "Show")
{
((LinkButton)e.Row.FindControl("lbtnView")).Visible = true;
((LinkButton)e.Row.FindControl("lbtnClose")).Visible = true;

}
else if (status.Trim() == "Close")
{
((LinkButton)e.Row.FindControl("lbtnView")).Visible = true;
((LinkButton)e.Row.FindControl("lbtnClose")).Visible = false;
lblRemarks.Visible = true;
labelRemark.Visible = true;
}

}
}
 
Share this answer
 
v2
Comments
praveena.karthi 29-Sep-11 6:20am    
Hello PGunge,

Thanks for your solution. But I have a problem, such as I am having a imagebutton if the condition is also false, It display 2 images.

Can you help me.

Pl send me the sample coding

Thnaks

Regards,
Praveen
member60 29-Sep-11 6:32am    
while desiging only first make it visible=false and depending on the condition value make it true or false at server side
praveena.karthi 7-Oct-11 1:26am    
Hello PGunge,

Thanks a lot for Solution. I solve my problem.
Once again thanks

Regards,
Praveen
member60 2-Nov-11 4:52am    
You Are WelCome
you can use row databound for displaying the image button in gridview.
if you want specific post some relevant code against what you want to check..
 
Share this answer
 
http://www.dotnetfunda.com/tutorials/controls/gridview.aspx


Please check this link....unfortunality you can get solution of your questation..
 
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