How do I access the data in a SqlDataSource? Here's what I'm trying to do:
The SQL will return only one row, but I'm not sure how to access the individual items in the SqlDataSource in order to set the page title to the description. Any suggestions?Code:protected void Page_Load(object sender, EventArgs e) { string id = Request.QueryString["id"]; if (id == null) return; string sql = "SELECT o.obj_id, o.description, o.desc_long, o.file_name, " + "o.file_path, o.t_image, o.sim, o.file_size, o.downloads, " + "o.obj_size, s.sim_name, s.sim_image FROM objects AS o " + "INNER JOIN sims AS s ON s.sim_id = o.sim " + "WHERE o.obj_id ='" + id + "'"; SqlDataSource1.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\stuff.mdf;Integrated Security=True;User Instance=True"; SqlDataSource1.SelectCommandType = SqlDataSourceCommandType.Text; SqlDataSource1.SelectCommand = sql; SqlDataSource1.DataBind(); this.Title = ""; // <- want this to be o.description }




Reply With Quote