betul Posted August 20, 2007 Share Posted August 20, 2007 Hi,I have a link label to list some news titles on my home page and as one clicked, it should send selected news' id to news page. Here is my Page_Load f'n; while(reader.Read()) { newsLabel.Text += "**"+ reader["NewsTitle"] + "<br/><br/>"; newsLabel.PostBackUrl = "News.aspx?id=" + reader["NewsID"]; } However, it sends the same id for each title. What I get is "http://Server/Project8/News.aspx?id=4" . Why doesn't it take the specific id of selected title? Thanks. Link to comment Share on other sites More sharing options...
Synook Posted August 20, 2007 Share Posted August 20, 2007 Because it will just send the last ID in your recordset. Think about it, say it loops for 4 records with IDs 1,2,3,4. First it sets the PostBackUrl with 1, then assigns 2, then assigns 3, then assigns 4. And every time what do we end up with? 4. You will have to limit your recordset when you call the reader.Open method so that it only selects a certain news item. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.