I am using a RadGrid and have some controls in columns. A DropDownList is in ItemTemplate (see code below). For example, when the grid was first bind with a dataset, "HI" was selected. I changed the selection to "AZ" and click another control in another column to call the Javascript function "showCityList" (see code below). Then I use Google F12 to step into the function. I have two questions.
1. I can see the var cell that has all states in the dropdownlist and "HI" is selected. <option selected="selected" value="HI">HI</option>. I changed the selection to "AZ". Why the initial state was still be selected?
2. How do I get the selected state? Please provide the syntax.
I CANNOT use OnSelectedIndexChanged and it is a long story to explain.
<telerik:GridTemplateColumn HeaderText=" State" SortExpression="State_Code" UniqueName="State_Code">
<ItemTemplate>
<asp:DropDownList ID="cboState" Width="105px" CssClass="State_Code" runat="server" ></asp:DropDownList>
</ItemTemplate>
</telerik:GridTemplateColumn>
function showCityList() {
var row = Telerik.Web.UI.Grid.GetFirstParentByTagName(button, "tr");
var rowIndex = row.id.split("__")[1];
debugger;
var MasterTable = $find("<%=gridSites.ClientID%>").get_masterTableView();
var selectedRows = MasterTable.get_dataItems();
if (selectedRows != null)
{
var row = selectedRows[rowIndex];
var cell = MasterTable.getCellByColumnUniqueName(row, "State_Code")
}
return false;
}
Thanks.