497988 Simple ASP.NET C# Code Fix


I'm using a repeater to list news article titles on a page. Once a title is clicked, the page reloads with the news details.

What I want to achieve is to compare the query string with the current news ID. If they are equal, then I want to give a different class name for the anchor tag to make the link highlighted with a different color.

It seems the repeater has some limitations. I want a fix for this, or an alternative for the repeater.

I need C# code sample please.

Here is my code:


ASPX Page:


<asp:Repeater runat="server" ID="rpNews">


<a href='[url removed, login to view];%#Eval("pubid") %>' class="news_header">

<%#Eval("title") %>





Code Behind:


using System;

using [url removed, login to view];

using [url removed, login to view];

using [url removed, login to view];

using [url removed, login to view];

using [url removed, login to view];

using [url removed, login to view];

using [url removed, login to view];

public partial class news : [url removed, login to view]


protected void Page_Load(object sender, EventArgs e)


// Get the MySQL connection string stored in the [url removed, login to view]

string cnnString = [url removed, login to view]["SqlConnStr"].ConnectionString;

// Create a connection object and data adapter

SqlConnection conn = new SqlConnection(cnnString);

SqlConnection conn2 = new SqlConnection(cnnString);

// Create a SQL command object

string cmdText = "SELECT * FROM news ORDER BY dt DESC";

string cmdText2 = "";

if([url removed, login to view]["pid"] == null)

cmdText2 = "SELECT TOP 1 * FROM news ORDER BY dt DESC";


cmdText2 = "SELECT * FROM news WHERE pubid = '" + [url removed, login to view]["pid"].ToString() + "'";

SqlCommand cmd = new SqlCommand(cmdText, conn);

SqlCommand cmd2 = new SqlCommand(cmdText2, conn2);

[url removed, login to view]();

SqlDataReader reader = [url removed, login to view]();

[url removed, login to view] = reader;

[url removed, login to view]();

[url removed, login to view]();

[url removed, login to view]();

SqlDataAdapter adapter = new SqlDataAdapter();

[url removed, login to view] = [url removed, login to view];

DataSet ds = new DataSet();

[url removed, login to view] = cmd2;

[url removed, login to view](ds);

string d = "";

string m = "";

string y = "";

foreach (DataRow dr in [url removed, login to view][0].Rows)


[url removed, login to view] = dr["title"].ToString();

y = dr["dt"].ToString().Substring(0,2);

m = dr["dt"].ToString().Substring(3,2);

d = dr["dt"].ToString().Substring(6,2);

[url removed, login to view] = d + "/" + m + "/" + y;

[url removed, login to view] = dr["content"].ToString().Replace("\r\n", "<br />");

[url removed, login to view]("src", "be/data/" + dr["pic"].ToString());

if (dr["pic"].ToString() == "")

[url removed, login to view] = false;


[url removed, login to view]();



Beceriler: .NET, Her şey Kabul, ASP, C# Programlama, MySQL, SQL

Daha fazlasını gör: what is system ui, what is substring, using configurationmanager, top query, substring in c, substring c, substring 0 2, net configurationmanager, my code, m string, id to code, get substring, get string c, fix the web, c substring, c string substring, configurationmanager.net 2.0, configurationmanager .net 2.0, configurationmanager.net, code top, code 6 d, code 5, c get string, asp net command, ui.net

İşveren Hakkında:
( 6 değerlendirme ) Zarqa, Jordan

Proje NO: #2243905



Hi choose me...

%selectedBids___i_period_sub_7% gün içinde 25%project_currencyDetails_sign_sub_9% %project_currencyDetails_code_sub_10%
(135 Değerlendirme)