How to display tabledata in sqlserver in a HTMLFILE
I have one html page now my task is to display tabledata in sqlserver in my html file please tell me procedure where i should write code and should i add a web.config file and xml file if so what is the use of adding them please help me iam not finding clarity
Jiteendra SampathiraoPosted Jul 21, 2011, 6:52 AM
In web.config file under appsettings
no need to use xml....
you can store the value in any control...
like
if (sqlred["a"] != null)
{
//if you want to dtore the value in text box do like this
textbox1.text = sqlred["a"].tostring();
}
if (sqlred["b"] != null)
{
textbox2.text = sqlred["b"].tostring();
}
sriram chvPosted Jul 21, 2011, 6:27 AM
Sam HobbsPosted Jul 21, 2011, 12:17 AM
How is the HTML page created?
Jiteendra SampathiraoPosted Jul 20, 2011, 8:23 AM
code behind page.........
private void Editing(string hdnvalue)
{
string selectquery = "";
selectquery = "select a,b,c,d,e,f FROM xyz;
SqlConnection sqlcon = new SqlConnection(ConfigurationManager.AppSettings["SqlServer"]);
SqlCommand sqlcomm = new SqlCommand();
sqlcomm = sqlcon.CreateCommand();
sqlcomm.CommandType = CommandType.Text;
sqlcomm.CommandText = selectquery;
sqlcon.Open();
SqlDataReader sqlred = null;
sqlred = sqlcomm.ExecuteReader();
if (sqlred.Read())
{
if (sqlred["a"] != null)
{
Label1.Text = sqlred["a"].ToString();
}
if (sqlred["b"] != null)
{
Label2.Text = sqlred["b"].ToString();
}
if (sqlred["c"] != null)
{
Label3.Text = sqlred["c"].ToString();
}
if (sqlred["d"] != null)
{
Label4.Text = sqlred["d"].ToString();
}
if (sqlred["e"] != null)
{
Label5.SelectedValue = sqlred["e"].ToString();
}
if (sqlred["f"] != null)
{
Label6.Text = sqlred["f"].ToString();
}
}
sqlcomm.Dispose();
sqlcon.Close();
}
write tblvaluesfromdatabase.visible=true; in ur event(ex: page_load or button click)
modify this code to your requirement..........
i hope it help you...........
sriram chvPosted Jul 20, 2011, 8:17 AM