I have a webform in asp.net.In that webform there is 2
division class(DIV).in one of the div class there is a text
box for enter the id & a button for to check id with
database value.My doubt is that how can i appear the 2nd
Div contents only when the id is true with database
value.if wrong do not display the div . i Want code in c#.

Answers were Sorted based on User's Feedback



I have a webform in asp.net.In that webform there is 2 division class(DIV).in one of the div class..

Answer / jyothis

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
string flag;
object dsd;
flag= setconnection();
if (flag=="True" )
{
dsd = getconnection();
MyDiv.Visible=true;
GridView1.DataSource = dsd;
GridView1.DataBind();
}

}
public object getconnection()
{
String constr =
ConfigurationManager.ConnectionStrings["ConnectDBString"].ConnectionString;
SqlConnection con = new SqlConnection();
con.ConnectionString = constr;

String query = "SELECT * FROM EMPLOYEE WHERE
EmployeeName = '" + TextBox1.Text + "'";
SqlCommand cmd = new SqlCommand();
cmd.CommandText = query;
cmd.Connection = con;
con.Open();

DataSet ds = new DataSet();
SqlDataAdapter adp = new SqlDataAdapter(cmd);
adp.Fill(ds,"EMPLOYEE");
return (ds);

con.Close();

}
public string setconnection()
{
String constr =
ConfigurationManager.ConnectionStrings["ConnectDBString"].ConnectionString;
SqlConnection con = new SqlConnection();
con.ConnectionString=constr;

String query = "SELECT * FROM EMPLOYEE WHERE
EmployeeName = '" + TextBox1.Text + "'";
SqlCommand cmd =new SqlCommand();
cmd.CommandText= query;
cmd.Connection=con;
con.Open();
string hd;
hd="False";
using (SqlDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{

int ID = (int)dr["ID"];
string Name = (string)dr["EmployeeName"];
}
if (dr.FieldCount >1)
{
hd="True";

}
}

return(hd);
con.Close();

}
}

Is This Answer Correct ?    1 Yes 0 No

I have a webform in asp.net.In that webform there is 2 division class(DIV).in one of the div class..

Answer / sam

We have give Property runat="server" for th division in aspx page

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

What is Cookies Less Session?

0 Answers  


Can I recieve both html markup for page and code in the asp.net web page's source code portion in the web browser?

0 Answers  


What is the mvc framework?

0 Answers  


What are the various types of validation controls provided by asp.net?

0 Answers  


Is asp.net 64-bit enabled? How?

0 Answers  






What is the Difference between user and server controls?

5 Answers  


code for "For every 5days system has to create 1text file with the corresponding date and it has to store in c-drive" by using web applications

0 Answers  


What is a web server? What are the load limits in it?

0 Answers   Wipro,


Is asp.net a programming language or framework?

0 Answers  


Describe the role of inetinfo.exe, aspnet_isapi.dll and aspnet_wp.exe in the page loading process

1 Answers   HCL, Siebel Systems, Visual Soft,


How do you register the .Net Component or Assembly?

2 Answers   Accenture,


there is two functions function a and function b like fun a(){.... ..... } fun b() { } in function b i write the coding to add two numbers and i need to dispaly the sum result in function a with out using global variable. how we do?

1 Answers  


Categories