Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a GridView with 3 columns ID, NAME, STATUS columns

When the status is yes, I want to send mail of that specific row. Any idea how can I select/filter rows which have status yes and send those rows in mail? Please help.

Any ideas are highly appreciated.

What I have tried:

Not sure how to filter gridview as per status and send those rows in mail
Posted
Updated 26-Apr-16 21:20pm
Comments
aarif moh shaikh 27-Apr-16 1:16am    
You can use DataView class in C#
Member 9017207 27-Apr-16 1:17am    
I'm a newbie. Can u pls give an example?

1 solution

In your button's onclick event, loop through the gridview. Find the control binded with Yes/No, use this control in an IF statement,
C#
foreach(GridViewRow gvRow in Gridview1.Rows)
{
   Label Label1 = (Label)gvRow.FindControl("Label1");
   if (Label1.Text =="YES") 
   { 
     //send email 
   }
}
 
Share this answer
 
Comments
Member 9017207 27-Apr-16 3:28am    
In the email body what to mention?
bjay tiamsic 27-Apr-16 3:58am    
in the //send email comment,
type there your code in sending email.
Member 9017207 27-Apr-16 4:04am    
in the findcontrol label1, I'll mention the column name?
bjay tiamsic 28-Apr-16 19:23pm    
No. Just put there the ID of the control that you bind the YES/NO field.

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