Click here to Skip to main content
15,860,844 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello all,

I have a question regarding gridview in C#.
I have a gridview control and i am fetching values from a database table and displaying them on gridview using boundfield. I have one column in gridview Ageing which is being calculated on daily basis. The gridview has a link button View Details and once we click on it, it redirects to next page which has also a gridview and the values are being fetched from database here as well. The second gridview has a column Status which can have value of 'Pending' or Closed.
Now what i want is if all the records in the second gridview has the Status = 'Closed' then i want to display a column TotalAge (The column is available in the database) in the first gridview but if any record has a status 'Pending' then i want to display the column Ageing in first gridview.
So the summary is i want to display either Ageing or Total Ageing Column based on the value of a column of another gridview.
I might not have explained it correctly so if you have any questions please feel free to ask.
Looking forward to your help.

Thanks

What I have tried:

Nothing related to this available on internet
Posted
Updated 2-Feb-17 23:00pm
v2

1 solution

You are not share any code, So as per my guess(assumption)
Send one more command argument by separating separator.
ASP.NET
<itemtemplate>
<asp:LinkButton ID="lnk" runat="server" Text="change status" OnClick="lnk_Click" CommandArgument='<%# Eval("Url")+ ";" +Eval("Status")>'></asp:LinkButton>
    </itemtemplate>


C#
protected void lnk_Click()
{
   string strVal = e.CommandArgument.ToString();
    string[] arg = new string[2];
     // split command argument
    char[] splitter = { ';' };
    arg = strVal .Split(splitter);
    // Get url
    string strUrl = arg[0].ToString();
    //Get staus
    string strStatus = arg[1].ToString();
    // Do whatever with status
}

Please share relevant code
 
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