The situation is Dropdownlist in Gridview.
While displaying the summary or reports we will use a Label for a particular column.
But in edit mode it must open in dropdownlist with selected Values as in the previous static mode.
I will explain clearly:
There is a table in database Months_TBL.
which contains 12 months.
1) First we must bind this with a datasource.
2) Attach this datasource to dropdown list.In the dropdownlist the query will be look like this
Select mid,month_name from Months_TBL.
3)Take a Template field for months which looks like this:
<asp:DropDownList CssClass=”textb” ID=”ddl1″ runat=”server” DataSourceID=”SqlDataSource1″ DataTextField=”month_name” DataValueField=”mid” AppendDataBoundItems=true selectedvalue=” >
<asp:Label ID=”Label1″ runat=”server” Text=”>
4) So While displaying if it shows February while we click edit the dropdown list will come as selected value as “February”.
Is it nice.
But carefully see that we have used “selectedvalue” property.