2015-01-02 3 views
-1

아래 코드에서 데이터 세트와 html 테이블이 있습니다. 제 경우에는 25 개의 데이터 세트가 있고 html 테이블에 바인딩하고 싶지만 첫 행만 바인딩합니다. 모든 행을 바인드하십시오.html 테이블에 데이터 세트를 바인딩하려면

MastersClient objIndent = new MastersClient(); 
       DataSet ds = objIndent.GetIndent(hidIndentID.Value); 

       DataRow[] drIndentID = ds.Tables[0].Select("IndentID =" + hidIndentID.Value); 
if (drIndentID.Length > 0) 
       { 
//Count is 25 
for (int i = 0; i < ds.Tables[0].Rows.Count; i++) 
         { 
          txtQty.Value = drIndentID[i]["RecommentedQuantity"].ToString(); 
          string strProductID = drIndentID[i]["ProductID"].ToString(); 
          ddlProduct.Text = strProductID; 
          txtDate.Text = drIndentID[i]["ProductRequiredDate"].ToString(); 
         } 

} 





<table id="dataTable" width="350px" border="1" runat="server"> 
     <tr> 
      <td><input id="checkbox" type="checkbox" name="chk" runat="server"/></td> 
      <td><input type="text" name="txt" id="txtQty" runat="server"/></td> 
      <td> 
      <asp:DropDownList ID="ddlProduct" runat="server" Style="width: 100%; height:23px" ></asp:DropDownList> 

      </td> 
      <td> 
      <asp:TextBox ID="txtDate" Style="text-align: left" onkeypress="return isNumberKey(event, false);" 
                 onblur="DateValidation(this)" onkeyup="ValidateDate(this, event.keyCode)" onkeydown="return DateFormat(this, event.keyCode)" 
                 Height="20px" runat="server" Width="80px"> </asp:TextBox> 


      </td> 
     </tr> 
    </table> 
+0

뒤에 영문, 당신은 당신이 오직 하나 하나 볼 이유입니다, 그렇게하지 않은 –

+0

참조 : http://stackoverflow.com/questions/9361729/create-a-html-table-with-an-asp-repeater-repeating-horizontally –

답변

0

당신이 당신의 테이블 행을 반복 중계기를 사용할 수 있습니다

<asp:Repeater ID="rptCategories" runat="server"> 
    <HeaderTemplate> 
     <table id="dataTable" width="350px" border="1"> 
    </HeaderTemplate> 
    <ItemTemplate> 
     <tr> 
      <td><input id="checkbox" type="checkbox" name="chk" runat="server"/></td> 
      <td><input type="text" name="txt" id="txtQty" runat="server"/></td> 
      <td> 
      <asp:DropDownList ID="ddlProduct" runat="server" Style="width: 100%; height:23px" >    </asp:DropDownList> 

      </td> 
      <td> 
      <asp:TextBox ID="txtDate" Style="text-align: left" onkeypress="return isNumberKey(event, false);" onblur="DateValidation(this)" onkeyup="ValidateDate(this, event.keyCode)" onkeydown="return DateFormat(this, event.keyCode)" Height="20px" runat="server" Width="80px"> </asp:TextBox> 


      </td> 
     </tr> 
    </ItemTemplate> 
    <FooterTemplate> 
     </table> 
    </FooterTemplate> 
</asp:Repeater> 

및 코드

  MastersClient objIndent = new MastersClient(); 
      DataSet ds = objIndent.GetIndent(hidIndentID.Value); 

      DataRow[] drIndentID = ds.Tables[0].Select("IndentID =" + hidIndentID.Value); 
      if (drIndentID.Length > 0) 
      { 
       rptCategories.DataSource=ds.Tables[0]; 
      } 
+0

오류가 발생합니다. ddlProduct가 없습니다. – Developer

+0

whi에서 ch 선?. –

+0

드롭 다운 목록을 바인드하는 메소드가 있습니다. ddlProduct.DataSource = dsProduct.Tables [1]; ddlProduct.DataTextField = "ProductName"; ddlProduct.DataValueField = "ProductID"; ddlProduct.DataBind(); – Developer

관련 문제