Click here to Skip to main content
15,936,565 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have a small requirement if anybody knows please let me know.

I have a dropdown list. It contains the list of product names and text box to enter the quantity. When I click the add button the details of product name and quantity should display in grid-view and when the user select next product in dropdown, the textbox should clear and possibility of adding new quantity and when user click add button the product details should append to gridview. Gridview should contains provious details also.
Updated 5-Sep-11 20:56pm

Check out this Code Project - Frequently Asked Questions Series 1: The ASP.Net GridView[^]
We have a similar post over there.
Share this answer
           <tr><td><asp:Label ID="lblFmlDate" runat="server" Text="Date"></asp:Label></td>
                <td><asp:TextBox ID="txtFmlDate"  runat="server" Enabled ="False"></asp:TextBox>
                    <asp:ImageButton ID="imgBtnFmlDate" ImageUrl="~/Images/Calendar_scheduleHS.png" runat="server" />
                    <AjaxToolkit:CalendarExtender ID="calExtrFmlDate"
                        OnClientDateSelectionChanged ="checkDate" runat="server"
                        TargetControlID="txtFmlDate" PopupButtonID="imgBtnFmlDate" Enabled="True">
            <td><asp:Label ID="lblDisease" runat="server" Text="Disease"></asp:Label></td>
            <td><asp:TextBox ID="txtDisease" Enabled ="False" runat="server" ></asp:TextBox></td>
            <td><asp:Button ID="cmdDiseaseAdd" Enabled ="False" runat="server" Text="Add"
                    width="60px" onclick="cmdDiseaseAdd_Click" ValidationGroup="B"/></td>
            <td><asp:Button ID="cmdDiseaseDel" Enabled ="False" runat="server" Text="Delete"
                    width="60px" onclick="cmdDiseaseDel_Click"/></td>

grid view 
            <td colspan="6">
            <asp:GridView ID="grdFmlHist" runat="server" AllowPaging="True" Enabled ="False"
            AutoGenerateColumns="False" DataKeyNames="Relationship" Height="40px" WIDTH="450px"
            PageSize="8" ShowFooter="True"  onrowdatabound="grdFmlHist_RowDataBound" >
            <PagerSettings Mode="NumericFirstLast" />
            <RowStyle BackColor="WhiteSmoke" BorderColor="CornflowerBlue" ForeColor="Black"
                Height="30px" />
            <asp:TemplateField HeaderText="S.No">
                      <asp:CheckBox ID="chkSelect" runat="server" />
                 <asp:TemplateField HeaderText="S.No">
                    <%# ((GridViewRow)Container).RowIndex + 1%>
                <asp:BoundField DataField="Relationship" HeaderText="Relationship" />
                <asp:BoundField DataField="Disease" HeaderText="Disease" />
                <asp:BoundField DataField="Dates" HeaderText="Dates" />
                    <asp:Button ID="btnDisplay" runat="server"  /></ItemTemplate>
            <FooterStyle BackColor="Silver" Height="25px" />
            <PagerStyle BackColor="DarkGray" />
            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />

After clicking on add button

protected void cmdDiseaseAdd_Click(object sender, EventArgs e)
           List<FmlDiseaseHist> fmlDiseaseList = new List<FmlDiseaseHist>();
           FmlDiseaseHist objFmlDiseaseHist = new FmlDiseaseHist();
           if (chkAddMandatory() == true)
               if (Session["FmlHist"] != null)
                   fmlDiseaseList = (List<FmlDiseaseHist>)(Session["FmlHist"]);

               if (string.IsNullOrEmpty(txtRelation.Text) != true)
                   objFmlDiseaseHist.Relationship = Convert.ToString(txtRelation.Text);
               if (string.IsNullOrEmpty(txtFmlDate.Text) != true)
                   objFmlDiseaseHist.Dates = txtFmlDate.Text;
               if (string.IsNullOrEmpty(txtDisease.Text) != true)
                   objFmlDiseaseHist.Disease = txtDisease.Text;
               txtRelation.Text = "";
               txtFmlDate.Text = dates.Date_Convert(dates.CurDateyyyymmdd());
               txtDisease.Text = "";
               Session["FmlHist"] = fmlDiseaseList;
               grdFmlHist.DataSource = fmlDiseaseList;
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900