protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { Literal DT = (Literal)repeater1.Controls[0].Controls[0].FindControl("DT"); Literal InvoiceNumber = (Literal)repeater1.Controls[0].Controls[0].FindControl("InvoiceNumber"); Literal Quote = (Literal)repeater1.Controls[0].Controls[0].FindControl("Quote"); Literal JobType = (Literal)repeater1.Controls[0].Controls[0].FindControl("JobType"); dynamic dataitem = e.Item.DataItem as dynamic; DTDiscrepancy d = (DTDiscrepancy)dataitem; if (fixheaderonce == 0) //don't need to run this code evertime hence the variable fixheaderonce { DT.Text = d.DTNumber; InvoiceNumber.Text = d.InvoiceNumber; Quote.Text = d.QuoteNumber; fixheaderonce = 2; } Literal DiscrType = (Literal)e.Item.FindControl("DiscrepancyType"); if (d.DiscrepancyType != currentDiscrepType) { DiscrType.Text = d.DiscrepancyType; currentDiscrepType = d.DiscrepancyType; } } }
public IEnumerable <DTDiscrepancy> GetDTDiscrepancy(int DTID) { var DTDiscrepancies = new List <DTDiscrepancy>(); using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SSIRentConnectionString"].ConnectionString)) using (SqlCommand command = connection.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "sp_dt_rptdtinvcquotediscrepancy"; command.Parameters.AddWithValue("@DTID", DTID); command.Parameters.AddWithValue("@DT", 1); command.Connection.Open(); using (SqlDataReader dr = command.ExecuteReader()) { while (dr.Read()) { var DTDiscrepancy = new DTDiscrepancy { DTNumber = dr["DeliveryTicketNumber"].ToString(), ItemDescription = dr["Description"].ToString(), QuoteNumber = dr["QuoteNumber"].ToString(), InvoiceNumber = dr["InvoiceNumber"].ToString(), Code = dr["Code"].ToString(), Quantity = Convert.ToInt32(dr["Quantity"]), QuoteQuantity = Convert.ToInt32(dr["QQuantity"]), AddDay = dr["Additional Day"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["Additional Day"]), QuoteAddDay = dr["QAddDay"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["QAddDay"]), Minimum = dr["Minimum"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["Minimum"]), QuoteMinimum = dr["QMinimum"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["QMinimum"]), DiscrepancyType = dr["DiscrepancyType"].ToString(), PrintColumn = dr["Minimum"] == DBNull.Value ? false : Convert.ToBoolean(dr["PrintColumn"]) }; DTDiscrepancies.Add(DTDiscrepancy); } } return(DTDiscrepancies); } }