I am trying to fetch a column value from a datasource when some value is selected from a dropdownlist on its change event.
<asp:DropDownList ID="ddlCityName" runat="server" DataSourceID="dsCity"
DataTextField="CityName" DataValueField="CityID" AutoPostBack="True"
OnTextChanged="CityName_OnTextChanged">
</asp:DropDownList>
<asp:SqlDataSource ID="dsCity" runat="server"
ConnectionString="<%$ ConnectionStrings:GmapConnectionString %>"
SelectCommand="SELECT * FROM [vcity]"></asp:SqlDataSource>
Here I want to fetch any other column's value that is not binded to a 开发者_运维技巧ddlCityName from sqldatasource.
I have four columns in datasource i.e. name, id, address, phno.
I want to fetch an address of a person who selects some value from ddl.
I don't know exactly how you can do that, but what I use in this situation is this, I combine my values together and add them all to the value field of DDList, for example you want ID and Address, so add them like this in your select query : select Cast(id as varchar) + '##' + address .... you can use any separator that you think will be unique, then just simply split the value string.
精彩评论