뒤에 내 C# 코드에서 txtCourseInfo의 값을 검색 할 내가 내 질문에서 의미가 무엇의 샘플의 예를 가지고 당신은 할 수 리피터를 사용하여 다음을 수행하십시오.
<asp:repeater id="rptCourses" runat="server" DataSourceID="dsCourseInfo"
<ItemTemplate>
<asp:TextBox ID="txtCourseInfo" Text='<%#Eval("StudentName")#%>' EnableViewState="false" CssClass="dataEntrySearchDataText" ReadOnly="true" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:Repeater>
<asp:sqldatasource id="dsCourseInfo"
ConnectionString="<%$ ConnectionStrings:YourConnectionString %>"
Select Command="Select * from Students">
</asp:sqldatasource>
코드 뒤에서 리피터의 컨트롤을 반복하고 정보를 얻을 수 있습니다.
텍스트 필드에 Eval
표현식이 표시되어 있습니다. 내가 예를 들어 "StudentName"를 사용하지만, 당신은 select statement
추가 의견에 의해 반환 된 열 이름 중 하나를 사용한다 :
- 그것은 여러면에서 나쁜 습관이다
select * from ...
하지 마십시오. 필요한 경우에도 항상 필요한 열을 지정하십시오.
- 나는 텍스트 상자에서 viewstate를 비활성화한다는 것을 알고 있습니다. 이 작업을 수행하는 이유를 알지 못하지만 컨트롤에서 활성화하지 않으면 정보가 후속 포스트 백에서 유지되지 않습니다.
UPDATE
예, 중계기 내부 테이블을 가질 수 있습니다. 아래 예를보세요 :
<ItemTemplate>
<table runat="server" style="color: White; background-color: #3A4F63;" visible="false"
id="headerTable">
<tr>
<td colspan="3" align="center">
<asp:Label ID="headerTitle" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td style="width: 200px; background-color: #3A4F63; color: White;">
Image
</td>
<td style="width: 200px;">
Studen Name
</td>
<td style="width: 200px;">
Birth Date
</td>
</tr>
</table>
<table>
<tr>
<td style="width: 200px;">
<asp:Image ID="img" runat="server" ImageUrl='<%#Eval("ImageUrl") %>'></asp:Image>
</td>
<td style="width: 200px;">
<asp:Label ID="lblName" runat="server" Text='<%#Eval("Name") %>'></asp:Label>
</td>
<td style="width: 200px;">
<asp:Label ID="lblBirthDate" runat="server" Text='<%#Eval("BirthDate") %>'></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
실행시 학생들의 목록을 표시합니까? –