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

Rate this:
Please Sign up or sign in to vote.

Solution 1

Hi Srinivas,

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

        onrowdatabound="gvName_RowDataBound1">
    </asp:GridView>


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
   

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