Tuesday, January 30, 2024

Linq Foreach and where caluse in asp.net

 var ProceedingsActiveList = CourtApplicationProceedingsList.Where(t => t.IsActive == true).ToList();


                ProceedingsActiveList.ForEach(p => { p.ConductingOfficerTypeName = ddlConductingProsecutor.Items.FindByValue(p.ConductingOfficerType.Value.ToString()).Text; p.LawOfficerName =  });

Finding DropDownList index by text - dropdown with foreach loop

 ddlsample.SelectedIndex = ddlsample.Items.IndexOf(ddlsample.Items.FindByValue("x")); // If you want to find text by value field.

ddlsample.SelectedIndex = ddlsample.Items.IndexOf(ddlsample.Items.FindByText("x"));// If you want to find text by TextField.




ProceedingsActiveList.ForEach(p => { p.ConductingOfficerTypeName = ddlConductingProsecutor.Items.FindByValue(p.ConductingOfficerType.Value.ToString()).Text;  });

reference:- https://stackoverflow.com/questions/5014864/finding-dropdownlist-index-by-text

Wednesday, January 24, 2024

How to show only date in repeater filed(column) from datetime dto object

asp:Repeater ID="rptStayDetails" runat="server">

                                        <ItemTemplate>

                                            <tr>

                                                <td>

                                                   <%#DataBinder.Eval(Container, "DataItem.DtOfStay","{0:dd-MM-yyyy}")%>

                                                </td>

Tuesday, January 23, 2024

How to save List of object to database with XML

 public void SaveAllActSectionDetailsList(long referenceId, long referenceType, List<ActSectionDetailsDTO> actSectionDetailsList)

        {

            actSectionDetailsList.ForEach(t => { t.ReferenceId = referenceId; t.ReferenceType= referenceType; });

            using (var actSectionDetailsClient = ServiceClient<IActSectionDetailsManager>.Create(ObjectConstants.ActSectionDetailsManager))

            {

                actSectionDetailsClient.Instance.InsertUpdateActSectionDetailsList(new ActSectionDetailsDTO { ActSectionDetailsList = actSectionDetailsList });

            }

        }


---------------  Entity ------------------


Initializes a new instance of the <see cref="ActSectionDetailsDTO"/> class.

        /// </summary>

        public ActSectionDetailsDTO()

        {

            ActSectionDetailsList = new List<ActSectionDetailsDTO>();

        }


        /// <summary>

        /// Gets or sets the act section details list.

        /// </summary>

        /// <value>The act section details list.</value>

        [XmlElement(ElementName = "ActSectionDetailsList")]

        public List<ActSectionDetailsDTO> ActSectionDetailsList { get; set; }