ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.[Solved] ASP.Net Error: Cannot implicitly convert type string to bool<p>Hi&nbsp;itsme,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <pre class="brush: html">&lt;fieldset style=&#34;width: 250px&#34;&gt; &lt;legend&gt;Select Time &lt;/legend&gt; From: &lt;asp:DropDownList ID=&#34;ddlTimeFrom&#34; runat=&#34;server&#34; OnSelectedIndexChanged=&#34;SelectedIndexChanged&#34; AutoPostBack=&#34;true&#34;&gt;&lt;/asp:DropDownList&gt; To: &lt;asp:DropDownList ID=&#34;ddlTimeTo&#34; runat=&#34;server&#34; OnSelectedIndexChanged=&#34;SelectedIndexChanged&#34; AutoPostBack=&#34;true&#34;&gt;&lt;/asp:DropDownList&gt; &lt;/fieldset&gt;&lt;br /&gt; &lt;asp:Label ID=&#34;lblOpenTime&#34; runat=&#34;server&#34; /&gt;</pre> <p><strong><span style="text-decoration: underline;">Code</span></strong></p> <p><strong>C#</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { BindTime(); } } protected void SelectedIndexChanged(object sender, EventArgs e) { List&lt;String&gt; mode = new List&lt;String&gt;(); if (ddlTimeFrom.SelectedIndex &gt; 0 &amp;&amp; ddlTimeTo.SelectedIndex &gt; 0) { mode.Add(ddlTimeFrom.Text); mode.Add(ddlTimeTo.Text); lblOpenTime.Text = &#34;Open Time : &#34; + string.Join(&#34;, &#34;, mode); } else { lblOpenTime.Text = &#34;&#34;; } } private void BindTime() { DateTime StartTime = DateTime.ParseExact(&#34;00:00&#34;, &#34;HH:mm&#34;, null); DateTime EndTime = DateTime.ParseExact(&#34;23:55&#34;, &#34;HH:mm&#34;, null); TimeSpan Interval = new TimeSpan(0, 5, 0); ddlTimeFrom.Items.Clear(); ddlTimeTo.Items.Clear(); while (StartTime &lt;= EndTime) { ddlTimeFrom.Items.Add(StartTime.ToShortTimeString()); ddlTimeTo.Items.Add(StartTime.ToShortTimeString()); StartTime = StartTime.Add(Interval); } ddlTimeFrom.Items.Insert(0, new ListItem(&#34;--Select--&#34;, &#34;0&#34;)); ddlTimeTo.Items.Insert(0, new ListItem(&#34;--Select--&#34;, &#34;0&#34;)); }</pre> <p><strong>VB.Net</strong></p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not Page.IsPostBack Then BindTime() End If End Sub Protected Sub SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Dim mode As List(Of String) = New List(Of String)() If ddlTimeFrom.SelectedIndex &gt; 0 AndAlso ddlTimeTo.SelectedIndex &gt; 0 Then mode.Add(ddlTimeFrom.Text) mode.Add(ddlTimeTo.Text) lblOpenTime.Text = &#34;Open Time : &#34; &amp; String.Join(&#34;, &#34;, mode) Else lblOpenTime.Text = &#34;&#34; End If End Sub Private Sub BindTime() Dim StartTime As DateTime = DateTime.ParseExact(&#34;00:00&#34;, &#34;HH:mm&#34;, Nothing) Dim EndTime As DateTime = DateTime.ParseExact(&#34;23:55&#34;, &#34;HH:mm&#34;, Nothing) Dim Interval As TimeSpan = New TimeSpan(0, 5, 0) ddlTimeFrom.Items.Clear() ddlTimeTo.Items.Clear() While StartTime &lt;= EndTime ddlTimeFrom.Items.Add(StartTime.ToShortTimeString()) ddlTimeTo.Items.Add(StartTime.ToShortTimeString()) StartTime = StartTime.Add(Interval) End While ddlTimeFrom.Items.Insert(0, New ListItem(&#34;--Select--&#34;, &#34;0&#34;)) ddlTimeTo.Items.Insert(0, New ListItem(&#34;--Select--&#34;, &#34;0&#34;)) End Sub</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/rNc2B9I.jpg" alt="" width="293" height="106" /></span></strong></p>https://www.aspforums.net:443/Threads/109292/Solved-ASPNet-Error-Cannot-implicitly-convert-type-string-to-bool/https://www.aspforums.net:443/Threads/109292/Solved-ASPNet-Error-Cannot-implicitly-convert-type-string-to-bool/Fri, 26 Jul 2019 03:48:41 GMT[Solved] ASP.Net Error: Cannot implicitly convert type string to bool<p>Thanky so much .....</p> <p>I also found a way to do this...</p> <pre class="brush: html">&lt;div&gt; &lt;fieldset style=&#34;width: 250px&#34;&gt; &lt;legend&gt;Select Time&lt;/legend&gt; From:&lt;asp:DropDownList ID=&#34;ddlTimeFrom&#34; runat=&#34;server&#34;&gt;&lt;/asp:DropDownList&gt; To:&lt;asp:DropDownList ID=&#34;ddlTimeTo&#34; runat=&#34;server&#34;&gt;&lt;/asp:DropDownList&gt; &lt;/fieldset&gt; &lt;/div&gt;</pre> <p>code behind:</p> <pre class="brush: csharp"> protected void btnLogin_Click(object sender, EventArgs e) { int i = 0; try { List&lt;string&gt; mode = new List&lt;string&gt;(); if (Cashpay.Checked) { mode.Add(Cashpay.Text); } if (Cardpay.Checked) { mode.Add(Cardpay.Text); } string payment = string.Join(&#34;, &#34;, mode); string start = ddlTimeFrom.SelectedValue.ToString(); string end = ddlTimeTo.SelectedValue.ToString(); string merge = string.Join(&#34;, &#34;, start, end); //Label1.Text = merge.ToString(); // Extract Image File Name. string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName); //Set the Image File Path. string filePath = &#34;~/uploads/&#34; + fileName; //Save the Image File in Folder. FileUpload1.PostedFile.SaveAs(Server.MapPath(filePath)); string constr = ConfigurationManager.ConnectionStrings[&#34;Q_SS_regnConnectionString1&#34;].ConnectionString; using (SqlConnection conn = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand(&#34;INSERT INTO Q_SP_Afterlogin (Bussiness_name,city,email,name,toll_free,website_link,payment_mode,Images,Image_name,address,h_open) VALUES (@Bname,@DropDownList2,@mail,@name,@toll,@link,@payment,@Image,@Image_name,@address,@open)&#34;, conn)) { cmd.Parameters.AddWithValue(&#34;@Bname&#34;, DropDownList1.SelectedValue.ToString()); cmd.Parameters.AddWithValue(&#34;@DropDownList2&#34;, DropDownList2.SelectedValue.ToString()); cmd.Parameters.AddWithValue(&#34;@mail&#34;, mail.Text.Trim().ToString()); cmd.Parameters.AddWithValue(&#34;@toll&#34;, toll.Text.Trim().ToString()); cmd.Parameters.AddWithValue(&#34;@link&#34;, link.Text.Trim().ToString()); cmd.Parameters.AddWithValue(&#34;@name&#34;, name.Text.Trim().ToString()); cmd.Parameters.AddWithValue(&#34;@address&#34;, address.Text.Trim().ToString()); cmd.Parameters.AddWithValue(&#34;@payment&#34;, payment); cmd.Parameters.AddWithValue(&#34;@Image&#34;, filePath); cmd.Parameters.AddWithValue(&#34;@Image_name&#34;,fileName); cmd.Parameters.AddWithValue(&#34;@open&#34;,merge); conn.Open(); i = cmd.ExecuteNonQuery(); conn.Close(); } } if (i &gt; 0) { lab.Text = &#34;Business information is added successfully.&#34;; lab.Visible = true; } else { lab.Text = &#34;Error while adding..!!&#34;; }</pre>https://www.aspforums.net:443/Threads/109292/Solved-ASPNet-Error-Cannot-implicitly-convert-type-string-to-bool/https://www.aspforums.net:443/Threads/109292/Solved-ASPNet-Error-Cannot-implicitly-convert-type-string-to-bool/Fri, 26 Jul 2019 03:58:30 GMT