Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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 http post and http get?

0 Answers  


What is the difference between CC and BCC?

0 Answers   MCN Solutions,


is it possible to use web site without web server from remote place?

1 Answers   ABC, Mannar Company, Quadrant,


How to consume a webservice in a windows application without adding through the web reference?

1 Answers   247Customer,


How do we make a poperty read only?

1 Answers   Microsoft,


What is ipostback?

0 Answers  


What is early binding and Late binding. Difference which is better ?

2 Answers   DELL,


Describe the difference between inline and code behind?

2 Answers  


Which method do you invoke on the DataAdapter control to load your generated dataset with data?

2 Answers   Siebel Systems,


Explain about Multi-Language integration?

0 Answers  


What is the relationship between IIS and ASP.NET in the generation of dynamic Web sites?

1 Answers  


Can you explain autopostback?

0 Answers  


Categories