Gurpreet Arora

Gurpreet Arora

  • 222
  • 7.8k
  • 593.6k

Data binding In asp.net

Jun 6 2018 11:19 AM
How I display State Code  in textbox  of the state that selected in dropdown
 
<div class="form-group col-md-3">
<label for="inputState" class="col-form-label">State</label>
<asp:DropDownList ID="State_Select" CssClass="form-control" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="States_Name" DataValueField="States_Id"></asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Retail_Billing %>" SelectCommand="SELECT * FROM [States] WHERE ([Country_Id] = @Country_Id)">
<SelectParameters>
<asp:Parameter DefaultValue="1" Name="Country_Id" Type="Byte" />
</SelectParameters>
</asp:SqlDataSource>
</div>
<div class="form-group col-md-3">
<label for="district" class="col-form-label">District</label>
<asp:DropDownList ID="District_Select" CssClass="form-control" runat="server" DataSourceID="SqlDataSource2" DataTextField="District_Name" DataValueField="District_Id" AutoPostBack="True"></asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:Retail_Billing %>" SelectCommand="SELECT * FROM [District] WHERE ([States_Id] = @States_Id)">
<SelectParameters>
<asp:ControlParameter ControlID="State_Select" DefaultValue="0" Name="States_Id" PropertyName="SelectedValue" Type="Byte" />
</SelectParameters>
</asp:SqlDataSource>
</div>
<div class="form-group col-md-3">
<label for="Location" class="col-form-label">Location</label>
<asp:DropDownList ID="Location_Drop" CssClass="form-control" runat="server" DataSourceID="SqlDataSource3" DataTextField="Location_Name" DataValueField="Location_Id"></asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:Retail_Billing %>" SelectCommand="SELECT * FROM [Location] WHERE ([District_Id] = @District_Id)">
<SelectParameters>
<asp:ControlParameter ControlID="District_Select" DefaultValue="0" Name="District_Id" PropertyName="SelectedValue" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</div>
<div class="form-group col-md-2">
<label for="inputZip" class="col-form-label">Zip</label>
<input type="text" class="form-control" placeholder="Zip" id="inputZip">
</div>
</div>

Answers (1)