-1

In the below code i have a dataset and html table .In my case i have dataset with 25 counts and i want to bind it to html table but it bind only first row .Pls help me to bind all rows .

 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>   
Developer
  • 83
  • 2
  • 8

1 Answers1

0

Your aspx

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

and Code behind

            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];
            }
صفي
  • 1,068
  • 2
  • 15
  • 34
  • I have a method which binds the dropdown list ddlProduct.DataSource = dsProduct.Tables[1]; ddlProduct.DataTextField = "ProductName"; ddlProduct.DataValueField = "ProductID"; ddlProduct.DataBind(); – Developer Jan 02 '15 at 13:24
  • Bind that dropdownlist on `repeater_itemdatabound`. – صفي Jan 02 '15 at 13:37