I actually found a way to do so.
<tr>
<td>
<b>State:</b>
</td>
<asp:Panel runat="server" ID="pnllbls" Visible="true">
<td>
<asp:TextBox ID="txtstate" runat="server" MaxLength="200" Width="250px" ReadOnly="true"></asp:TextBox>
</td>
</asp:Panel>
<asp:Panel runat="server" ID="pnlstate" Visible="false">
<td>
<asp:DropDownList ID="State" runat="server" class="form-control input-lg" DataSourceID="SqlDataSource1" DataTextField="State"
DataValueField="SId" OnSelectedIndexChanged="State_SelectedIndexChanged" AutoPostBack="true" AppendDataBoundItems="true">
<asp:ListItem Value="0">--Select--</asp:ListItem>
</asp:DropDownList><br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT DISTINCT SId,State FROM [State]"></asp:SqlDataSource>
</td>
</asp:Panel>
</tr>
<tr>
<td>
<b>City:</b>
</td>
<asp:Panel runat="server" ID="pnllblc" Visible="true">
<td>
<asp:TextBox ID="txtcity" runat="server" MaxLength="200" Width="250px" ReadOnly="true"></asp:TextBox>
</td>
</asp:Panel>
<asp:Panel runat="server" ID="pnlcity" Visible="false">
<td>
<asp:DropDownList ID="city" runat="server" class="form-control input-lg" DataSourceID="SqlDataSource2"
DataTextField="City" DataValueField="Id" AutoPostBack="true" AppendDataBoundItems="false">
<asp:ListItem Value="0">--Select City--</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT DISTINCT [Id], [City] FROM [City] WHERE ([SId] = @SId)">
<SelectParameters>
<asp:SessionParameter Name="SId" SessionField="sid" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</asp:Panel>
</tr>
<tr>
<asp:Panel runat="server" ID="pnlbtn">
<td colspan="2" align="center">
<asp:Button ID="btnchange" runat="server" Text="Edit" CssClass="btn btn-info" OnClick="btnstate_Click" Width="50px" Height="30px" />
</td>
</asp:Panel>
</tr>
<tr>
if (!IsPostBack)
{
mycon.Close();
mycon.Open();
cmd.Connection = mycon;
cmd.CommandType = CommandType.Text;
cmd.CommandText = "Select City,State,phone,Contact_person,Address,Company_website from Company_profile where email='" + Session["mail"].ToString() + "'";
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
txtstate.Text = dr["State"].ToString();
txtcity.Text = dr["City"].ToString();
txt_no.Text = dr["phone"].ToString();
txt_Contact.Text = dr["Contact_person"].ToString();
txt_address.Text = dr["Address"].ToString();
weblink.Text = dr["Company_website"].ToString();
btnsave.Visible = false;
btnUpdate.Visible = true;
}
}
}
protected void btnstate_Click(object sender, EventArgs e)
{
pnlcity.Visible = true;
pnlstate.Visible = true;
pnllbls.Visible = false;
pnllblc.Visible = false;
pnlbtn.Visible = false;
}