2012-11-29 3 views
3

내 페이지에 몇 개의 텍스트 상자가 있고 데이터베이스의 데이터로 채우고 싶습니다. 나는 쿼리를 수행하고 (필자의 경우) 필자가 텍스트 박스를 채우기 위해 사용하는 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; 
} 

영화의 필름 객체가 있지만 어떤 이유로 텍스트 상자는 텍스트를 표시하지 않습니다 다음은 내 코드입니다.

전체 페이지에 대한 코드 (즉, 관련) :

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; 
    } 

나는 거의 모든 곳에서 중단 점을 넣어 시도했습니다

<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> 

에서 .aspx 페이지와 텍스트 상자는 텍스트에 대한 값을 가지고 있지만 페이지에서 그것은 비어있는 채로 남아 있습니까?

+0

당신이 데이터 바인딩하는 유일한 곳입니까? 어디에서이 방법을 부릅니까? 'TextBoxes'의 aspx를 보여줄 수 있습니까? –

+0

디버깅을 시도해 보았습니까? 실제로 필름 객체에 텍스트가 있는지 확인 했습니까? – Pavenhimself

+0

왜 Textbox를 사용하고 있습니까? 여기에 레이블을 사용하여 데이터를 표시 할 수 있습니다. 또한 Textbox.Text는 NOT get 작업입니다. – CodeSpread

답변

2

당신의 updatetemplate 사용자가 입력 할 텍스트 상자가 포함되어 있는지 확인하는 것이 좋습니다 수 있습니다.

0

왜 레코드 집합을 사용하지 않습니까? 그것은 매우 쉽게 쓸 수 있으며 내가 당신의 상황에 대한 좋은 생각 : Here more info

관련 문제