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:
Hi,

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.
Posted
Updated 5-Sep-11 20:56pm
v2

Check out this Code Project - Frequently Asked Questions Series 1: The ASP.Net GridView[^]
We have a similar post over there.
 
Share this answer
 
javascript
XML
<table>
           <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">
                    </AjaxToolkit:CalendarExtender>
            </td></tr>
            <tr>
            <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>
            </tr><tr>

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" />
            <Columns>
            <asp:TemplateField HeaderText="S.No">
                  <ItemTemplate>
                      <asp:CheckBox ID="chkSelect" runat="server" />
                </ItemTemplate>
                 </asp:TemplateField>
                 <asp:TemplateField HeaderText="S.No">
                  <ItemTemplate>
                    <%# ((GridViewRow)Container).RowIndex + 1%>
                </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Relationship" HeaderText="Relationship" />
                <asp:BoundField DataField="Disease" HeaderText="Disease" />
                <asp:BoundField DataField="Dates" HeaderText="Dates" />
                <asp:TemplateField>
                <ItemTemplate>
                    <asp:Button ID="btnDisplay" runat="server"  /></ItemTemplate>
                </asp:TemplateField>
              </Columns>
            <FooterStyle BackColor="Silver" Height="25px" />
            <PagerStyle BackColor="DarkGray" />
            <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
        </asp:GridView></td></tr>


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 = "";
               fmlDiseaseList.Add(objFmlDiseaseHist);
               Session["FmlHist"] = fmlDiseaseList;
               grdFmlHist.DataSource = fmlDiseaseList;
               grdFmlHist.DataBind();
           }
       }
 
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