So I have a Datatable that is supposed to show information. I have it working in Windows Forms but tranfering it over to asp.net so a little diffrent. I do not understand GridViews that much. So any help would be appreciative.

I will not give everything away. I did a break and noticed that all the information was getting recieved but the gridview was not showing up. All of this is on page load.

dr = dt.NewRow();
        try
        {
            dt.Rows.Clear();
            dt.Rows.Clear();
            dt.Rows.Clear();
            dt = new DataTable("MyTable");
            dt.Columns.Add("Scale");
            dt.Columns.Add("Cases");
            dt.Columns.Add("Cases2", Type.GetType("System.String"));
            dt.Columns.Add("Cases3", Type.GetType("System.String"));
            dt.Columns.Add("Cases4", Type.GetType("System.String"));
            dt.Columns.Add("Cases5", Type.GetType("System.String"));
            dt.Columns.Add("Cases6", Type.GetType("System.String"));
            dt.Columns.Add("Cases7", Type.GetType("System.String"));
            dt.Columns.Add("Cases8", Type.GetType("System.String"));
            dt.Columns.Add("Cases9", Type.GetType("System.String"));
            dt.Columns.Add("Cases10", Type.GetType("System.String"));



            List<ManifestData> Data = GetManifestData(Start);
            if (Data != null && Data.Count > 0)
            {
                List<Standards> Standards = GetStandards(Data);

                //get scale numbers
                var a = (from d in Data select d.Scale).Distinct();

                //sort by scale where it will be displayed in order
                a = a.OrderBy(z => z.Value);

                TimeSpan t1 = new TimeSpan(), t2 = new TimeSpan(), t3 = new TimeSpan(), t4 = new TimeSpan(),
                         t5 = new TimeSpan(), t6 = new TimeSpan();
                foreach (int i in a)
                {
                    //get percentages for each scale
                    ScaleData s = GetPercentages(Data, Standards, i);

                    if (s != null)
                    {
                        if (s.ActualTarget != 0 && s.AdjustedTarget != 0)
                        {
                            //display percentages for scale
                            GridView1.Rows.Add = (new object[] { -info });

                        }

                       GridView2.Rows.Add(new object[] { -info }
                        t1 += s.ActualTime;
                        t2 += s.AdjustedTime;
                        t3 += s.ActualTimeWithChangeOvers;
                        t4 += s.AdjTimeWithChangeOvers;
                        t5 += (s.ActualTimeWithChangeOvers - s.ActualTime);
                        t6 += (s.ActualTimeWithChangeOvers - s.AdjTimeWithChangeOvers);

                    }
                }
                //add totals line
                if (GridView2.Rows.Count > 0)
                {
                    double cases = 0, target = 0, target2 = 0;
                    foreach (GridViewRow r in GridView2.Rows)
                    {
                       -info
                    }

                    GridView2.Rows.Add(new object[] { -info });
                }

                if (GridView2.Rows.Count > 0)
                {
                    int cases = 0, changeovers = 0;

                    foreach (GridViewRow r in GridView2.Rows)
                    {
                        -info
                    }

                    GridView2.Rows.Add(new object[] { -info});
                }

            }
            else
            {

            }
        }
        catch (Exception ex)
        {
            Label1.Text = "Error" + ex;   
        }

I deleted a lot of things and just put -info. You dont really need the code I believe. Just need help with things like Gridview.Rows.Add

 cases += Convert.ToInt32(r.Cells[1].Value.ToString());
                        changeovers += Convert.ToInt32(r.Cells[2].Value.ToString());

.Value does not work.

Any help would be awesome.

Thanks.

Fgured it out needed to make some Columns in the code. Worked out.

Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.