应该设置它的SelectedItemIndex
System.IO.File fl= new System.IO.File ();
System.IO.File fl= new System.IO.File ();
解决方案 »
- 丢失Session问题
- js修改其他网页的title
- ext.net checkbox 选中删除的问题
- 在flash的第一帧处播放另一个flash
- GridView和ListView控件都是表格控件。想问一下,哪一个控件运行效率高一点啊?
- 如何在页面中使用AJAX控件
- c#中读取select 下拉框
- 关于获取URL的问题
- 如何设置一个网页的url!!!!
- 如何不出现url后面的参数
- 想要微软msn上的所有图标,这个主意不错,讨论一下怎么获取
- 请问为什么出现“Visual Studio .NET 已检测到指定的 Web 服务器运行的不是 ASP.NET 1.1版。您将无法运行 ASP.NET Web 应用程序或服务。
using System;
using System.IO;class Test
{
public static void Main()
{
string path = @"c:\temp\MyTest.txt";
if (!File.Exists(path))
{
// Create a file to write to.
using (StreamWriter sw = File.CreateText(path))
{
sw.WriteLine("Hello");
sw.WriteLine("And");
sw.WriteLine("Welcome");
}
} // Open the file to read from.
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
} try
{
string path2 = path + "temp";
// Ensure that the target does not exist.
File.Delete(path2); // Copy the file.
File.Copy(path, path2);
Console.WriteLine("{0} was copied to {1}.", path, path2); // Delete the newly created file.
File.Delete(path2);
Console.WriteLine("{0} was successfully deleted.", path2);
}
catch (Exception e)
{
Console.WriteLine("The process failed: {0}", e.ToString());
}
}
}
DropDownList.SelectedIndex = DropDownList.Items.IndexOf(DropDownList.Items.FindByValue(Request.QueryString("传递的值")))
SelectedIndex 已重写。获取或设置 DropDownList 控件中的选定项的索引。
SelectedItem(从 ListControl 继承) 获取列表控件中索引最小的选定项。
SelectedValue(从 ListControl 继承) 获取列表控件中选定项的值,或选择列表控件中包含指定值的项。
你要设置,不是获取,所以只能用SelectedIndex ,先找到对应的内容项的index,再设定SelectIndex
2.
是否没有引用System.IO.File
using System.IO.File;
如果不是我就不清楚了,可能Framework有问题了。
for(int i=0;i<DropDownList1.Items.Count;i++)
{
if(DropDownList1.Items[i].Text==Request["type"])
{
DropDownList1.SelectedIndex=i;
}
}
DropDownList1.DataBind();
要用楼上的说的DropDownList.SelectedItem才行
using System.IO;...
File.Delete...
//就OK了﹐奇怪怎么在VB.net里卻可以先定義成一個變量