数据绑定和显示文本框中的数据 [英] Data binding and display data in textbox

查看:79
本文介绍了数据绑定和显示文本框中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我绑定数据库的下拉菜单



国家/地区|国家|区|城市



下拉工作正常我想在文本框中显示状态代码,在状态表中显示State_Code



问题我在下拉列表中选择的状态我想在文本框中显示该状态的State_Code



我尝试了什么:



Hello

i am binding a dropdown with Database

Country | State | District | City

Dropdown is working fine I want to show state Code in textbox and State_Code in State Table

Question Which States I select in dropdown i want to show the State_Code of that State in Textbox

What I have tried:

<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>

推荐答案

ConnectionStrings:Retail_Billing%>SelectCommand =SELECT * FROM [States] WHERE([Country_Id] = @Country_Id)>
< SelectParameters>
< asp:参数DefaultValue =1Name =Country_IdType =Byte/>
< / SelectParameters>
< / asp:SqlDataSource>

< / div>

< div class =form-group col-md-3>
< label for =districtclass =col-form-label>区< / label>
< asp:DropDownList ID =District_SelectCssClass =form-controlrunat = serverDataSourceID =SqlDataSource2DataTextField =District_NameDataValueField =District_IdAutoPostBack =True>< / asp:DropDownList>
< asp:SqlDataSource ID =SqlDataSource2runat =serverConnectionString =<%
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_SelectDefaultValue =0Name =States_IdPropertyName =SelectedValueType =Byte/>
< / SelectParameters>
< / asp:SqlDataSource>
< / div>
< div class =form-group col-md-3>
< label for =Locationclass =col-form-label>位置< / label>
< asp:DropDownList ID =Location_DropCssClass =form-controlrunat =serverDataSourceID =SqlDataSource3DataTextField =Location_NameDataValueField =Location_Id>< / asp:DropDownList>
< asp:SqlDataSource ID =SqlDataSource3runat =serverConnectionString =<%
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_SelectDefaultValue =0Name =District_IdPropertyName =SelectedValueType =Int32/>
< / SelectParameters>
< / asp:SqlDataSource>
< / div>


< div class =form-group col-md-2>
< label for =inputZipclass =col-form-label> Zip< / label>
< input type =textclass =form-controlplaceholder =Zipid =inputZip>
< / div>
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>


这篇关于数据绑定和显示文本框中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆