0

Below code is from Course.aspx

 <asp:Image runat="server" ImageUrl="ShowImage.ashx?id={?}" alt="" Width="600px" Height="450px" />

Below code is from CourseDetail.cs

var courseid = Request.QueryString["courseid"].ToString();
string sql = "SELECT * FROM Course where CourseID=@CourseID";
string[] name = { "@CourseID" };
string[] value = { courseid };
DataTable dt = DataBase.SQLselect(sql, name, value);

ShowImage.ashx?id={courseid} this code works great. I check with any current number suc as ShowImage.ashx?id=5.

Now I want to know how I shloud call CourseID in Course.aspx :

ImageUrl="ShowImage.ashx?id={CourseID} ??

2
  • I thought you said the code works great? Whats the problem... Commented Apr 10, 2014 at 6:40
  • I mean that when I write ShowImage.ashx?id=5 manually , it works, But I need to use CourseID such as ShowImage.ashx?id={Call CourseID} . Commented Apr 10, 2014 at 6:43

1 Answer 1

2

In aspx side put ID to your element.

 <asp:Image runat="server" ID="imgCourse" alt="" Width="600px" Height="450px" />

Than in .cs side call your object.

imgCourse.ImageUrl="ShowImage.ashx?id=" + dt.courseID.ToString();
Sign up to request clarification or add additional context in comments.

3 Comments

But genereally Dont you know how can I write as I said ?
What do you mean? Do you want to bind data in aspx side? If yes, your element has to be in repeter,listview etc. And you can bind ID from datasource which is already binded to repeter. For this kind of single element its easy and efficient to set data in .cs side.
here I dont need repeater. For example you sign in facebook.com and when you go to your Profil page you can see your data (forexample profilphoto).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.