<asp:GridView ID="GridView1" ShowFooter="True" AutoGenerateColumns="False" runat="server" > <Columns> <asp:TemplateField HeaderText="Products/Services"> <ItemTemplate> <asp:DropDownList ID="DropDownProducts" Width="150px" runat="server" CssClass="RegistryDrop" AutoPostBack="true" OnSelectedIndexChanged="DropDownProducts_SelectedIndexChanged" DataSourceID="datasourceProducts" DataTextField="Name" DataValueField="ProdId"> </asp:DropDownList> <asp:SqlDataSource ID="datasourceProducts" runat="server" ConnectionString="<%$ ConnectionStrings:EasyCut %>" SelectCommand="SELECT [Name], [ProdId] FROM [tbl_ProdServ]"></asp:SqlDataSource> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Price"> <ItemTemplate> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Quantity"> <ItemTemplate> <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> </ItemTemplate> <FooterStyle HorizontalAlign="Right" /> <FooterTemplate> <asp:Button ID="ButtonAdd" OnClick="btn_add_Click" runat="server" Text="Submit" /> </FooterTemplate> </asp:TemplateField> </Columns> </asp:GridView>
protected void DropDownProducts_SelectedIndexChanged(object sender, EventArgs e) { TextBox box1=(TextBox)GridView1.Rows[e.currentrow].Cells[2].FindControl("TextBox2"); DropDownList dl=(DropDownList)GridView1.Rows[e.currentrow].Cells[2].FindControl("DropDownProducts"); box1.Text = dl.SelectedValue.ToString(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)