Hi !
I'm currently working on a website with asp.NET 4.0 and c#.
I need to implemente a User control in a listview. I want the listview to show a list of data from a table name Lignes (with a ligne_id as primary key) and the user control to show a list of data from a table name Blocks (with a block_id as primary key and a ligne_id as foreign key).
Here's the code I made :
My Listview :
My UserControl :
My user control's code Behind :
When I execute this code, the label ligne_id from the listview has the good ligne_id from the database (so Text='<%# Eval("ligne_id") %>' is working) but the Label1 from the user control is always at 0 (so Ligne_ID='<%# Eval("ligne_id") %>' doesn't seem to work).
Do you have an idea what is wrong with my code ?
Thanks in advance for you awnser
P.S : I'm french so I'm sorry if I'm not very clear in my explanation.
I'm currently working on a website with asp.NET 4.0 and c#.
I need to implemente a User control in a listview. I want the listview to show a list of data from a table name Lignes (with a ligne_id as primary key) and the user control to show a list of data from a table name Blocks (with a block_id as primary key and a ligne_id as foreign key).
Here's the code I made :
My Listview :
<
asp:ListView
ID
=
"ListView1"
runat
=
"server"
DataKeyNames
=
"ligne_id"
DataSourceID
=
"SqlDataSourceLigne"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"ligne_id"
ClientIDMode
=
"Static"
runat
=
"server"
Text='<%# Eval("ligne_id") %>' />
<
uc1:UC_ListeBlock
ID
=
"UC_ListeBlock1"
runat
=
"server"
Ligne_ID='<%# Eval("ligne_id") %>' />
</
ItemTemplate
>
</
asp:ListView
>
My UserControl :
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text
=
"Label"
></
asp:Label
>
My user control's code Behind :
public
partial
class
UC_ListeBlock : System.Web.UI.UserControl
{
public
Int32 Ligne_ID;
private
Int32 ligne_ID
{
get
{
return
Ligne_ID; }
set
{ Ligne_ID = value; }
}
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!Page.IsPostBack)
{
Label1.Text = ligne_ID.ToString();
}
}
}
When I execute this code, the label ligne_id from the listview has the good ligne_id from the database (so Text='<%# Eval("ligne_id") %>' is working) but the Label1 from the user control is always at 0 (so Ligne_ID='<%# Eval("ligne_id") %>' doesn't seem to work).
Do you have an idea what is wrong with my code ?
Thanks in advance for you awnser
P.S : I'm french so I'm sorry if I'm not very clear in my explanation.