I have entered data into textbox and stored in sql server in the page1. Now i want to retrieve that entered data into dropdown list and also when that category appears in dropdownlist , i have a textbox where i can select a category from dropdownlist and enter the data related to that category in page 2.. In page 3 , i want a gridview to display the contents in the dropdown list ....
please help me out. i am new into .net
Thanks and regards
Antony
Loading
antony victorPosted Jun 5, 2013, 4:29 PM
Pankaj PandeyPosted Jun 3, 2013, 9:05 AM
On third page pic a ddl with autopostback true property.
on page load...
write this code..
on ddl selectedindexchanged event write this code
mark as answered if its helpful.
thanks
antony victorPosted Jun 3, 2013, 8:17 AM
Pankaj PandeyPosted Jun 3, 2013, 7:59 AM
for page 2..
add namespace---
using System.Data;
using System.Data.SqlClient;
add this code to yout page_load event after put your real data(database name,tablename,fieldname etc..)
SqlConnection conn = new SqlConnection(@"server=servername;User Id=sa;Password=yourpassword;Initial Catalog=databasename");
SqlCommand cmd = new SqlCommand("select yourcolumn from your table1", conn);
cmd.CommandTimeout = 0;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "column name";
DropDownList1.DataValueField = "column name";
DropDownList1.DataBind();
after that on your button click event write this code..to save data...
SqlConnection conn = new SqlConnection(@"server=servername;User Id=sa;Password=yourpassword;Initial Catalog=databasename");
SqlCommand cmd = new SqlCommand("insert into table2 (ddlfield,ttextfield) values("+DropDownList1.SelectedItem.Text+","+TextBox1.Text+")", conn);
cmd.CommandTimeout = 0;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
if i am going in right direction then do it and then tell me..i'll give code for page 3.
Sunny SharmaPosted Jun 3, 2013, 7:36 AM
Consider forming the question properly so that we better understand your requirements. Please remember that we cannot read your mind/HardDisk. Please explain a little more.