Hi
according to below thread I use code in my page
Highlight-text-in-datalist/
and I change my code like below
protected void HouseP_Click(object sender, EventArgs e)
{
string openingTag = "<span style='background-color:Yellow'><b>";
string closingTag = "</b></span>";
SqlCommand _cmd = new SqlCommand("AdminSearchP", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cn.Open();
SqlDataReader dr = _cmd.ExecuteReader();
if (dr.HasRows)
{
dr[1]= dr[1].ToString().Replace(dr[2].ToString(), openingTag + dr[2].ToString() + closingTag);
DataList1.DataSource = dr;
DataList1.DataBind();
}
_cn.Close();
}
But below error happen
Server Error in '/behtop website' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0200: Property or indexer 'System.Data.Common.DbDataReader.this[int]' cannot be assigned to -- it is read only
Source Error:
|
Line 73: if (dr.HasRows)
Line 74: {
Line 75: dr[1]= dr[1].ToString().Replace(dr[2].ToString(), openingTag + dr[2].ToString() + closingTag); Line 76:
Line 77: DataList1.DataSource = dr;
|
Source File: d:\behtop project\behtop website\7.26\behtop website\Admin\search.aspx.cs Line: 75
what should i do ?
Best Regards