Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am using gridview for displaying data , here i retrieve few rows of information from database, In this i have amount column . i have to add all the retrieved rows amount column if the total amount will be 0 , i have to show status as close in gridview. how to do above functionality
help me please
Posted
Updated 8-Feb-11 20:10pm
v2
Comments
Sandeep Mewara 9-Feb-11 1:53am    
Good. So, what is the issue. You know what all to be done, try!

Post issues if you face.
Sunasara Imdadhusen 9-Feb-11 2:03am    
What is problem?
ngthtra 9-Feb-11 2:18am    
Can you tell me your problem?
srinivasvempa 9-Feb-11 2:20am    
hi i dont know how to set status in gridview based on database value

1 solution

Hi Srinivas,

Please do the following:
I have added DataKeyNames=Total to the gridview
XML
<asp:GridView DataKeyNames="Total" ID="gvName" runat="server"
        onrowdatabound="gvName_RowDataBound1">
    </asp:GridView>


C#
protected void gvName_RowDataBound(object sender, GridViewRowEventArgs e)
   {
       if (e.Row.RowType == DataControlRowType.DataRow)
       {
           int total = Convert.ToInt32(gvName.DataKeys[0].Value);
           if (total == 0)
           {
               //I assumed your 4th number of column is for Account Status
               e.Row.Cells[3].Text = "Closed";
           }
       }
   }


Thanks,
Imdadhusen
 
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