2013-08-18 2 views
0

5 개의 열이있는 데이터를 준비한 각 레이블에 바인딩하려고합니다. 예제 :sqlserver에서 레이블에 데이터 바인딩

(ROW1, COL1) 바인드 내 데이터베이스 행 수가 달라질 수

을 LABEL2하는 (ROW1, COL2) 바인딩 LABEL1하기 위해서는 등 5 행, 6 행 될 수 열은 정확히 5입니다. 뒤에있는 코드를 도울 수 있습니까? 사용자가 버튼을 누를 때 바인딩해야합니다.

여기 여기 내 영문 코드

<div style="margin-top:10px; border:solid 2px #7bc1f7; border-radius:20px; padding:10px;"> 
    <p> 
     <asp:Label ID="lbl_semester" Text="Semester" runat="server" Height="20px" Width="100px"></asp:Label>: 
     <asp:TextBox ID="txt_semester" runat="server" Height="20px" Width="20px"></asp:TextBox> 
    </p> 

    <p> 
     <asp:Label ID="lbl_nama" Text="Nama" runat="server" Height="20px" Width="100px"></asp:Label>: 
     <asp:TextBox ID="txt_nama" runat="server" Height="20px" Width="220px"></asp:TextBox> 
     <asp:ImageButton ID="find_btn1" runat="server" ImageUrl="~/Images/search-icon.png" Height="20px" Width="20px" ImageAlign="AbsMiddle" /> 
    </p> 

    <p> 
     <asp:Label ID="lbl_nim" Text="NIM" runat="server" Height="20px" Width="100px"></asp:Label>: 
     <asp:TextBox ID="txt_nim" runat="server" Height="20px" Width="220px"></asp:TextBox> 
     <asp:ImageButton ID="find_btn2" runat="server" ImageUrl="~/Images/search-icon.png" Height="20px" Width="20px" ImageAlign="AbsMiddle" /> 
    </p> 
</div> 
<div style="margin-top:10px; border:solid 2px #7bc1f7; border-radius:20px; padding:10px;"> 
    <asp:Label ID="Label1" runat="server" Text="NO" Height="20px" Width="25px"></asp:Label>&nbsp;&nbsp 
    <asp:Label ID="Label14" runat="server" Text="KODE" Height="20px" Width="85px"></asp:Label>&nbsp;&nbsp;&nbsp;&nbsp; 
    <asp:Label ID="Label16" runat="server" Text="MATA KULIAH" Height="20px" Width="300px"></asp:Label>&nbsp;&nbsp;&nbsp; 
    <asp:Label ID="Label17" runat="server" Text="SKS" Height="20px" Width="40px"></asp:Label>&nbsp; 
    <asp:Label ID="Label18" runat="server" Text="NILAI" Height="20px" Width="300px"></asp:Label>&nbsp;&nbsp;&nbsp; 
    <asp:Label ID="Label19" runat="server" Text="SKN" Height="20px" Width="35px"></asp:Label><br /> 

    <asp:Label ID="Label2" runat="server" Text="1" Height="20px" Width="25px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_kode_mk1" Text="-" runat="server" Width="85px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_mk1" Text="*****" runat="server" Width="300px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_sks1" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_nilai1" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_skn1" Text="-" runat="server" Width="20px"></asp:Label> 
    <asp:CheckBox ID="CheckBox1" runat="server" Width="5px" /><br /> 

    <asp:Label ID="Label3" runat="server" Text="2" Height="20px" Width="25px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_kode_mk2" Text="-" runat="server" Width="85px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_mk2" Text="*****" runat="server" Width="300px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_sks2" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_nilai2" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_skn2" Text="-" runat="server" Width="20px"></asp:Label> 
    <asp:CheckBox ID="CheckBox2" runat="server" Width="5px" /><br /> 

    <asp:Label ID="Label4" runat="server" Text="3" Height="20px" Width="25px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_kode_mk3" Text="-" runat="server" Width="85px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_mk3" Text="*****" runat="server" Width="300px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_sks3" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_nilai3" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_skn3" Text="-" runat="server" Width="20px"></asp:Label> 
    <asp:CheckBox ID="CheckBox3" runat="server" Width="5px" /><br /> 

    <asp:Label ID="Label5" runat="server" Text="4" Height="20px" Width="25px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_kode_mk4" Text="-" runat="server" Width="85px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_mk4" Text="*****" runat="server" Width="300px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_sks4" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_nilai4" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_skn4" Text="-" runat="server" Width="20px"></asp:Label> 
    <asp:CheckBox ID="CheckBox4" runat="server" Width="5px" /><br /> 

    <asp:Label ID="Label6" runat="server" Text="5" Height="20px" Width="25px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_kode_mk5" Text="-" runat="server" Width="85px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_mk5" Text="*****" runat="server" Width="300px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_sks5" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_nilai5" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_skn5" Text="-" runat="server" Width="20px"></asp:Label> 
    <asp:CheckBox ID="CheckBox5" runat="server" Width="5px" /><br /> 

    <asp:Label ID="Label7" runat="server" Text="6" Height="20px" Width="25px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_kode_mk6" Text="-" runat="server" Width="85px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_mk6" Text="*****" runat="server" Width="300px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_sks6" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_nilai6" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_skn6" Text="-" runat="server" Width="20px"></asp:Label> 
    <asp:CheckBox ID="CheckBox6" runat="server" Width="5px" /><br /> 

    <asp:Label ID="Label8" runat="server" Text="7" Height="20px" Width="25px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_kode_mk7" Text="-" runat="server" Width="85px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_mk7" Text="*****" runat="server" Width="300px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_sks7" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_nilai7" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_skn7" Text="-" runat="server" Width="20px"></asp:Label> 
    <asp:CheckBox ID="CheckBox7" runat="server" Width="5px" /><br /> 

    <asp:Label ID="Label9" runat="server" Text="8" Height="20px" Width="25px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_kode_mk8" Text="-" runat="server" Width="85px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_mk8" Text="*****" runat="server" Width="300px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_sks8" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_nilai8" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_skn8" Text="-" runat="server" Width="20px"></asp:Label> 
    <asp:CheckBox ID="CheckBox8" runat="server" Width="5px" /><br /> 

    <asp:Label ID="Label10" runat="server" Text="9" Height="20px" Width="25px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_kode_mk9" Text="-" runat="server" Width="85px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_mk9" Text="*****" runat="server" Width="300px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_sks9" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_nilai9" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_skn9" Text="-" runat="server" Width="20px"></asp:Label> 
    <asp:CheckBox ID="CheckBox9" runat="server" Width="5px" /><br /> 

    <asp:Label ID="Label11" runat="server" Text="10" Height="20px" Width="25px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_kode_mk10" Text="-" runat="server" Width="85px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_mk10" Text="*****" runat="server" Width="300px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_sks10" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_nilai10" Text="-" runat="server" Width="20px"></asp:Label>&nbsp;&nbsp; 
    <asp:Label ID="lbl_skn10" Text="-" runat="server" Width="20px"></asp:Label> 
    <asp:CheckBox ID="CheckBox10" runat="server" Width="5px" /><br /> 
</div> 

+1

데이터를 표시하려면 Gridview를 사용할 수 있습니다. – Raghubar

+0

그래, 실제로 그래,하지만 표시 된 데이터의 값을 다음 다른 단추를 사용하여 다른 데이터베이스 테이블에 삽입해야합니다. –

+0

그 U에 대한 루프를 수있는 gridview 레이블 컨트롤을 찾은 다음 합계를 계산할 수 있습니다. – Raghubar

답변

0

얼마나 루프의 gridview를에, 예입니다.

double tot = 0; 
    foreach (GridViewRow gvRow in GridView1.Rows) 
    { 
     Label lblGT = (Label)gvRow.FindControl("lblinvGrandTotal"); 
     if (lblGT.Text != "") 
     { 
      tot += Convert.ToDouble(lblGT.Text); 
     } 
    } 
관련 문제