views:

17

answers:

0

I want to show the following data on a Gridview.

  • Request ID
  • Email
  • Date
  • User Type
  • Status

Status can be Active or Inactive according to the database value.if its Inactive user must be able to change the status to Active so that the database value will be updated.I couldn't implement this Status field as a linkbutton field.following is the code that i'm currently using to bind the data to GridView.Can any one help me regarding this!!!

private void FillGrdRequests(List<UserRegTypeProperties> LURTP)
    {
        DataTable PDtable = new DataTable();
        GrdRequests.DataSource = PDtable;
        GrdRequests.DataBind();

        PDtable.Columns.Add("Request ID");
        PDtable.Columns.Add("Email");
        PDtable.Columns.Add("Date");
        PDtable.Columns.Add("User Type");
        PDtable.Columns.Add("Status");

        GrdRequests.DataSource = PDtable;
        GrdRequests.DataBind();

        foreach (UserRegTypeProperties URTP in LURTP)
        {
            PDtable = (DataTable)GrdRequests.DataSource;
            PDtable.Rows.Add(PDtable.NewRow());
            PDtable.Rows[PDtable.Rows.Count - 1][0] = URTP.RRID.ToString();
            PDtable.Rows[PDtable.Rows.Count - 1][1] = URTP.To.ToString();
            PDtable.Rows[PDtable.Rows.Count - 1][2] = URTP.Sent_Date.ToShortDateString();
            string Utype="";
            string Ustatus = "";
            if (URTP.UserType == "A")
            {
                Utype = "Admin";
            }
            else
            {
                Utype = "Internal";
            }
            PDtable.Rows[PDtable.Rows.Count - 1][3] = Utype;
            if (URTP.IsConfirmed == true)
            {
                Ustatus = "Active";
            }
            else
            {
                Ustatus = "Inactive";
            }
            PDtable.Rows[PDtable.Rows.Count - 1][4] = Ustatus;
        }

        PDtable = (DataTable)GrdRequests.DataSource;
        GrdRequests.DataSource = PDtable;
        GrdRequests.DataBind();
    }