Hey , guys

i'm just beginner , and wanna little help ..

i have two WebPages ( Default1 & Default2 )

in each one i put Datalist control

in default1 the Datalist reading data from SQL DB and i edit Item Template to put Hyberlink reading from DB (Item_Name) !!

in Default2 , i wanna make DataList reading data from DB (Item_Details) Depending on User Choice of HyberLink in Default1 !!


ofcourse i shall using QueryString !!


so , how can i use it ti resolve this issue !!


- sorry for my Weak English !!


waitng for ur replies !!

ur question is not clear...
pls provide example if u cant explain wat u really need..

see the attachment !!

Northwind DB

Hi Major,
You have to change NavigateUrl's bind property of Hyperlink on default.aspx.

Eval("ProductName","~/Default2.aspx?pname={0}")

and code of Default2.aspx should be,

string productname=Request["pname"]; // QueryString key
 SqlConnection cnn = new SqlConnection("Data Source=HAFEZ\\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True");
        DataTable dt = new DataTable("Emp");
        SqlCommand cmd = new SqlCommand("select quantityperunit , unitprice from products where productname='" + productname + "'", cnn);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        cnn.Open();
        da.Fill(dt);
        DataList1.DataSource = dt;
        DataList1.DataBind();

Hi Major,
You have to change NavigateUrl's bind property of Hyperlink on default.aspx.

Eval("ProductName","~/Default2.aspx?pname={0}")

and code of Default2.aspx should be,

string productname=Request["pname"]; // QueryString key
 SqlConnection cnn = new SqlConnection("Data Source=HAFEZ\\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True");
        DataTable dt = new DataTable("Emp");
        SqlCommand cmd = new SqlCommand("select quantityperunit , unitprice from products where productname='" + productname + "'", cnn);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        cnn.Open();
        da.Fill(dt);
        DataList1.DataSource = dt;
        DataList1.DataBind();

thanks alot ...

there's lttile issue here ...

it shows Error messages when clicking some Items(hyberlinks) !!!!

the error :

Incorrect syntax near 's'.
Unclosed quotation mark after the character string ''.

it mark code : da.Fill(dt);

Post code of Default2.aspx.cs. Source code must be surrounded with code tags.
for example,

[code=asp.net] .... ....

[/code]

pls ignore this

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.