You can use ajax auto complete extender for the text box that will look like drop down list..
1. Add auto comlete extender in the grid view inside Edit Item template
<asp:textbox runat="server" id="txtState" autopostback="true" cssclass="txtClass" xmlns:asp="#unknown">
<asp:autocompleteextender id="AutoDepartmentFrom" runat="server" delimitercharacters="" xmlns:asp="#unknown">
Enabled="True" ServicePath="" MinimumPrefixLength="0" ServiceMethod="GetCompletionList"
ContextKey="State" UseContextKey="True" CompletionListElementID="Div1"
TargetControlID="txtState" CompletionInterval="100" EnableCaching="true">
2.Add a service method in the code behinde to serve this text box
<system.web.services.webmethod()> _
Shared Function GetCompletionList(ByVal prefixText As String, ByVal contextKey As String) As String()
Dim Obj As New CriticalIndentRequirement
Dim ItemArray As String()
ItemArray = Obj.GetIntelligenceList(prefixText, contextKey)
Return ItemArray
End Function
if you press A then it will list the names of the states which starts from A
write a function to add query
Public Function GetIntelligenceList(ByVal prefixText As String, ByVal contextKey As String) As String()
Dim ColumnName As String = String.Empty
Dim items As New List(Of String)
Dim sqlquery As String = String.Empty
Dim Count As Integer = 0
Try
'Values extracted from tables based on type of user logged in
If contextKey = "state" Then
sqlquery = "select Top 10 stateName from state where stateName like '" & prefixText & "%'"
ColumnName = "MachineId"
End If
If contextKey = "DrawingNo" Then
sqlquery = "select cityName from city where cityName like '" & prefixText & "%'"
ColumnName = "DrawingNo"
End If
Dim AdptCompleteList As New SqlDataAdapter(sqlquery, CMScn)
Dim dtFilteredList As New DataTable
'Fill query result in a datatable
AdptCompleteList.Fill(dtFilteredList)
Dim itemList As String
'SuggestionList stored from datatable to an array called itemList
Dim dr As DataRow
For Each dr In dtFilteredList.Rows
itemList = dr(ColumnName).ToString()
items.Add(itemList)
Count += 1
Next
Return items.ToArray()
Catch ex As Exception
WriteToLog("MachineDispatch Page - Autoextender for Machine Log: " & ex.ToString())
Return Nothing
End Try
End Function
3.Text Change Event of state call city