Hi
I use datalist in page that put lable and Linkbutton on this datalist
1-LblSW
below is code for Linkbutton
protected void Lbview_Click(object sender, EventArgs e)
{
this.GetCustomersPageWiseView(1);
}
private void GetCustomersPageWiseView(int pageIndex)
{
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand cmd = General.GetCommand("GetCustomersPageWiseMC", conn))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@PageIndex", pageIndex);
cmd.Parameters.AddWithValue("@PageSize", PageSize);
cmd.Parameters.AddWithValue("@Genre", ddlGenre.SelectedItem.Text);
cmd.Parameters.AddWithValue("@SameWord", LblSW.Text);
cmd.Parameters.Add("@RecordCount", SqlDbType.Int, 4);
cmd.Parameters["@RecordCount"].Direction = ParameterDirection.Output;
conn.Open();
SqlDataReader idr = cmd.ExecuteReader();
if (idr.HasRows)
{
DLFilm.DataSource = idr;
DLFilm.DataBind();
rptPager3.Visible = !(rptPager2.Visible = rptPager.Visible =/* DLrandom.Visible =*/ false);
}
idr.Close();
this.PopulatePagerPLS(Convert.ToInt32(cmd.Parameters["@RecordCount"].Value), pageIndex);
}
}
}
but this error happen:
Server Error in '/' 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: CS0103: The name 'LblSW' does not exist in the current context
becuse LblSw is in datalist:
<asp:DataList ID="DLFilm" runat="server" RepeatDirection="Vertical" CssClass="Dlfilm">
<ItemTemplate>
<asp:LinkButton ID="LBview" runat="server" CssClass="lbother" OnClick="Lbview_Click">مشاهده دیگر قسمت های این فیلم</asp:LinkButton>
<asp:Label ID="LblSW" runat="server" CssClass="lblSW" Text='<%# Eval("SameWord") %>'></asp:Label>
</ItemTemplate>
</asp:DataList>
what should I do now?
Best regards
Neda