You must Sign In to post a response.
  • Category: Silverlight

    Datagrid row and column value

    Hi ,

    I have a datagrid with 3 rows and 3 cols.I am populating some values by applying some condition in 1st row last cell and 2nd row last cell as a result 3rd row last cell is empty.

    Now, I need to write some logic in 3rd row last colum:

    say 1 st row last cell value is A.
    2nd row last cell value is B.

    Now I have to write C -(A+B) in 3rd row last cell value of datagrid.

    Please help .


    Regards,
  • #753564
    Hi,

    If you want to perform some calculation based on some condition on your datasource control then refer below sample this might be helpful to you.


    int a=0,b=0;
    protected void GV_OnRowDataBound(object sender, GridViewRowEventArgs e)
    {
    if(e.Row.RowType==DataControlRowType.DataRow)
    {
    int index=e.Row.RowIndex;
    if(index==0)
    {
    a=((Label)e.Row.FindControl("lblval")).Text;
    }
    else if(index==1)
    {
    b=((Label)e.Row.FindControl("lblval")).Text;
    }
    else if(index==2)
    {
    c=a+b;
    ((Label)e.Row.FindControl("lblval")).Text=c.ToString();
    }
    }
    }


    Try something like above to achieve your goal..

    Hope this will helpful to you to achieve your goal..

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


  • Sign In to post your comments