Click here to Skip to main content
14,267,298 members
Rate this:
Please Sign up or sign in to vote.
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
Rate this:
Please Sign up or sign in to vote.

Solution 3

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;
}

}
}
   
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
Rate this:
Please Sign up or sign in to vote.

Solution 1

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..
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

http://www.dotnetfunda.com/tutorials/controls/gridview.aspx


Please check this link....unfortunality you can get solution of your questation..
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100