我有一个填充的DropDownList.如何找到Text值为“x”的索引?
解决方法
如果你想在服务器端获得价值,你可以按照这个.
ddlsample.SelectedIndex = ddlsample.Items.IndexOf(ddlsample.Items.FindByValue("x")); // If you want to find text by value field. ddlsample.SelectedIndex = ddlsample.Items.IndexOf(ddlsample.Items.FindByText("x"));// If you want to find text by TextField.