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.Disable Button if data already exist in Database using C# in ASP.Net<p>Hi <a class="username" rel="VinitaAkha"> VinitaAkha</a>,</p> <p>Refer the updated code.</p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session[&#34;User&#34;] == null) { Response.Redirect(&#34;login.aspx&#34;); } else { try { con.Open(); cmd11.Connection = con; cmd11.CommandType = CommandType.Text; cmd11.CommandText = &#34;SELECT DISTINCT AddRaw_199.Id,AddRaw_199.Name,AddRaw_199.Contact,AddRaw_199.District,AddRaw_199.Address,AddRaw_199.State,AddRaw_199.Status,AddRaw_199.Email,AddRaw_199.PoQuantity,Company_Data199.PQuantity,Total=AddRaw_199.PoQuantity*Company_Data199.PQuantity FROM AddRaw_199 INNER JOIN Company_Data199 ON AddRaw_199.Id = Company_Data199.Id where AddRaw_199.Status = 0 and AddRaw_199.Company_Email = Company_Data199.Email and PoQuantity != 0 and AddRaw_199.Email=&#39;&#34; + Session[&#34;User&#34;].ToString() + &#34;&#39;&#34;; SqlDataReader dr = cmd11.ExecuteReader(); if (dr.HasRows) { if (dr.Read()) { Button1.Visible = false; } else { Button1.Visible = true; } } } catch (Exception) { throw; } finally { con.Close(); } try { con.Open(); cmd11.Connection = con; cmd11.CommandType = CommandType.Text; cmd11.CommandText = &#34;select Email from Company_Data199 where Id=&#39;&#34; + Request.QueryString[&#34;Id&#34;].ToString() + &#34;&#39;&#34;; SqlDataReader dr = cmd11.ExecuteReader(); if (dr.HasRows) { if (dr.Read()) { ename.Text = dr[&#34;Email&#34;].ToString(); ename.ReadOnly = true; } } } catch (Exception) { throw; } finally { con.Close(); } try { con.Open(); cmd11.Connection = con; cmd11.CommandType = CommandType.Text; cmd11.CommandText = &#34;select Name,Email,Contact,Address,District,State from RegistrationAll_199 where Email=&#39;&#34; + Session[&#34;User&#34;].ToString() + &#34;&#39;&#34;; SqlDataReader dr = cmd11.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { name.Text = dr[&#34;Name&#34;].ToString(); name.ReadOnly = true; Email.Text = dr[&#34;Email&#34;].ToString(); Email.ReadOnly = true; cont.Text = dr[&#34;Contact&#34;].ToString(); cont.ReadOnly = true; add.Text = dr[&#34;Address&#34;].ToString(); add.ReadOnly = true; dis.Text = dr[&#34;District&#34;].ToString(); dis.ReadOnly = true; state.Text = dr[&#34;State&#34;].ToString(); state.ReadOnly = true; } } } catch (Exception) { throw; } finally { con.Close(); } Session[&#34;new&#34;] = name.Text.Trim().ToString(); Label1.Text = Request.QueryString[&#34;Id&#34;].ToString(); } } }</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/152480/Disable-Button-if-data-already-exist-in-Database-using-C-in-ASPNet/https://www.aspforums.net:443/Threads/152480/Disable-Button-if-data-already-exist-in-Database-using-C-in-ASPNet/Tue, 03 Sep 2019 04:57:31 GMT