Click here to Skip to main content
14,971,029 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I have dropdown list inside the grid, while edit the row in grid i need to display the previous value in the drop down list .

Please help .

Thanks
Mohan
Posted
Comments
Rockstar_ 5-Oct-12 0:49am
   
Onrowdatabound event you have to write the code to get the dropdownvalue.

XML
<asp:GridView ID="GrdSample"  CssClass="task-table"  runat="server" Width="485px"  AutoGenerateColumns="False"
                                        AllowPaging="True" PageSize="12">
                                        <Columns>
                                            <asp:BoundField DataField="ColName" HeaderText="Name"  />
                                            <asp:BoundField DataField="ColAge" HeaderText="Age"  />

                                            <asp:TemplateField HeaderText="Delete"   >

                                               <ItemTemplate  >

                                                   <asp:DropDownList ID="ddlSubject"    AutoPostBack="True" onselectedindexchanged="ddlSubject_SelectedIndexChanged"  Width = "100px" runat="server"> </asp:DropDownList>


                                               </ItemTemplate>

                                                <FooterStyle HorizontalAlign="Center" />

                                                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Top" />

                                                <ItemStyle HorizontalAlign="Center" />

                                             </asp:TemplateField>

                                        </Columns>
                                    </asp:GridView>

C# code:
C#
DropDownList ddlSubject = (DropDownList)GrdSample.Rows[iCount-1].FindControl("ddlSubject");

and then you can get any value of dropdown list and display any where , you can take a label in itemtemplate column and display it .
   
v4
hi friend,

use hidden controls like this
ASP.NET
<asp:Label ID="something" style="display:none" Text="" runat="server"></asp:Label>


then store your previous dropdownlist value in LblPrevious.
for examples:
C#
LblPrevious.Text="your Dropdownlist value";


regards
sarva
   
v4

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