我的页面上有几个文本框,想用数据库中的数据填充它们。我进行查询并获取(在我的情况下)我用来填充文本框的 Film 对象,但它不起作用。这是我的代码:
private void FilmInfo(int gekozenFilm)
{
BLFilm blFilm = new BLFilm();
Film film = blFilm.GetFilmById(gekozenFilm);
TextBoxFilm.Text = film.Naam;
TextBoxRelease.Text = film.Releasedatum.ToString();
TextBoxTrailer.Text = film.Filmpje;
TextBoxAfbeelding.Text = film.Afbeelding;
}
电影中有一个 Film 对象,但由于某种原因,文本框不显示文本。
整个页面的代码(相关):
protected void ListBoxMovies_SelectedIndexChanged(object sender, EventArgs e)
{
int gekozenFilm;
gekozenFilm = Convert.ToInt32(ListBoxMovies.SelectedItem.Value);
FilmInfo(gekozenFilm);
}
private void FilmInfo(int gekozenFilm)
{
BLFilm blFilm = new BLFilm();
Film film = blFilm.GetFilmById(gekozenFilm);
TextBoxFilm.Text = film.Naam;
TextBoxRelease.Text = film.Releasedatum.ToString();
TextBoxTrailer.Text = film.Filmpje;
TextBoxAfbeelding.Text = film.Afbeelding;
}
.aspx 页面
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<section id="context">
<article id="left">
<h2>Movie CRUD</h2>
<div class="seperator">
<!-- seperator -->
<asp:Label ID="LabelNaam" runat="server" Text="Naam"></asp:Label>
<asp:TextBox ID="TextBoxFilm" runat="server" Width="250px"></asp:TextBox>
<br />
<asp:Label ID="LabelRelease" runat="server" Text="Releasedatum"></asp:Label>
<asp:TextBox ID="TextBoxRelease" runat="server" Width="185px"></asp:TextBox>
<br />
<asp:Label ID="LabelTrailer" runat="server" Text="Trailer"></asp:Label>
<asp:TextBox ID="TextBoxTrailer" runat="server" Width="241px"></asp:TextBox>
<br />
<asp:Label ID="Label1" runat="server" Text="Afbeelding"></asp:Label>
<asp:TextBox ID="TextBoxAfbeelding" runat="server" Width="209px"></asp:TextBox>
</div>
</article>
<article id="right">
<h2>Movies</h2>
<asp:ListBox ID="ListBoxMovies" runat="server" Height="141px" Width="315px" OnSelectedIndexChanged="ListBoxMovies_SelectedIndexChanged" ViewStateMode="Inherit" AutoPostBack="True"></asp:ListBox>
</article>
</section>
</form>
我已经尝试在几乎所有地方放置断点并且文本框具有文本值但在页面上它仍然是空的?