hello you all,

thanks you all for solving my problems and helping and guiding me.

i have news titles with hyperlink in one page when i click on one of the news title then it will navigate to other page and will display news title and content there.

now i have passed session news_id to content dipslaying page in repeater.

<td><asp:HyperLink ID="HyperLink1" navigateurl='<%# String.Format("Default.aspx?News_Id={0}", Eval("News_Id")) %>' runat="server"><%#DataBinder.Eval(Container.DataItem,"News_Title") %></asp:HyperLink></td>

how can i receive news_title and News_content on other.

i have to fetch news_content from database and i m using asp.net2.0.

Dani AI

Generated

As described, the list page hands an identifier to the details page; and are right that the details page should fetch the DB row on load. Below is a straightforward, safe pattern: validate the incoming id, run a parameterized MySQL query, then bind the result to a Repeater or simple Label/Literal controls.

Example server-side pattern (validate id separately and pass it into BindNews):

using MySql.Data.MySqlClient;
using System.Data;
using System.Configuration;

private void BindNews(int id)
{
    string cs = ConfigurationManager.ConnectionStrings["MySqlConn"].ConnectionString;
    using (var conn = new MySqlConnection(cs))
    using (var cmd = new MySqlCommand("SELECT News_Title, News_Content FROM news WHERE News_Id = @id", conn))
    {
        cmd.Parameters.AddWithValue("@id", id);
        using (var da = new MySqlDataAdapter(cmd))
        {
            var dt = new DataTable();
            da.Fill(dt);
            rptNews.DataSource = dt;
            rptNews.DataBind();
        }
    }
}

Minimal Repeater ItemTemplate you can use on the details page:

<asp:Repeater ID="rptNews" runat="server">
  <ItemTemplate>
    <h2><%# Eval("News_Title") %></h2>
    <div><%# Eval("News_Content") %></div>
  </ItemTemplate>
</asp:Repeater>

Notes and troubleshooting: always validate that the id is an integer and > 0 before calling BindNews. Use parameterized queries (shown) to avoid SQL injection. If News_Content stores HTML, only render it raw after you sanitize it on input; otherwise HtmlEncode titles and content to prevent XSS. If nothing appears, check the connection string name, confirm the table/column names match, ensure DataBind() runs on first load (not blocked by incorrect IsPostBack logic), and verify the MySQL .NET connector is referenced. If you prefer session-based transfer (as suggested earlier), still validate and cast the session value before using it.

Recommended Answers

All 4 Replies

hello you all,

thanks you all for solving my problems and helping and guiding me.

i have news titles with hyperlink in one page when i click on one of the news title then it will navigate to other page and will display news title and content there.

now i have passed session news_id to content dipslaying page in repeater.

<td><asp:HyperLink ID="HyperLink1" navigateurl='<%# String.Format("Default.aspx?News_Id={0}", Eval("News_Id")) %>' runat="server"><%#DataBinder.Eval(Container.DataItem,"News_Title") %></asp:HyperLink></td>

how can i receive news_title and News_content on other.

i have to fetch news_content from database and i m using asp.net2.0.

hi,

As of your code u r passing the News_id value using querystring. You can get the value on the other page using

Request.QueryString["New_id"];

But, u also need to get the value of "News_Title" too. Here, u have to pass the same through querystring.

But, the better way to go is Session.

Assign the required values to session as follows.

Session["News_id"]=News_id;
Session["News_title"]=News_title;

i hope this will help u. otherwise let me know.

explain ur case in detail..
wot do u want exactly..and which are the controls u r using to achieve this..!

i know how to use session and request.querystring but passing News_Id using hyperlink is new for me.

problem is that

when i pass News_Id using hyperlink from news.aspx it will navigate to news1.aspx page and there in repeater it will show the News_Title and News_content from database.
i have no idea how to do this??

please guide me about this idea

>news1.aspx page and there in repeater it will show the News_Title and News_content

Write code in Page_load handler that fetch rows from the table based upon given news_id.

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.