我有一个奇怪的问题.我们来看看那段代码:
TreeNode tn = TreeView1.FindNode("2009/08/12 (1)"); //OK, the Node is found
Run Code Online (Sandbox Code Playgroud)
现在,我需要删除该节点:
(它不工作!)
(例如(我知道我不需要使用TreeView1.FindNode()方法,但是i = -1))
TreeNode tn1 = TreeView1.FindNode(tn.ValuePath);
int i = TreeView1.Nodes.IndexOf(tn1);
Run Code Online (Sandbox Code Playgroud)
要么
TreeView1.Nodes.Remove(tn);
Run Code Online (Sandbox Code Playgroud)
问题是,上面的代码不起作用,我的意思是,节点没有删除,为什么?TreeView看起来像这样:
alt text http://img130.imageshack.us/img130/230/71970321.png
我已经定义了我的课程:
public class Host
{
public string Name;
}
Run Code Online (Sandbox Code Playgroud)
然后是强类型字典:
Dictionary<string, Host> HostsTable;
Run Code Online (Sandbox Code Playgroud)
然后我尝试比较一个值:
if (HostsTable.Values.Where(s => s.Name == "myhostname") != null) { doSomething }
Run Code Online (Sandbox Code Playgroud)
问题是,没有找到任何东西,即使我确定该项目在列表中.我做错了什么?
在我的页面上,我有许多html控件看起来像这样:
<span id="pic1" class="container">
<span class="inner">
<span class="img"></span>
<span class="strip"></span>
<span class="remove_the_main_container"></span>
</span>
</span>
Run Code Online (Sandbox Code Playgroud)
所有我想要做的,是删除(通过使用jQuery)的span用class="container"时,用户点击在span用class="remove_the_main_container".问题是 - 如何获取最上面的容器的ID,其中放置了单击的span(class="remove_the_main_container")?
我想知道在tsql(CTE)中是否存在递归更新
ID parentID value
-- -------- -----
1 NULL 0
2 1 0
3 2 0
4 3 0
5 4 0
6 5 0
Run Code Online (Sandbox Code Playgroud)
我可以value使用例如从ID = 6的CTE到最顶行来递归地更新列吗?
我想在一个内部渲染一个PartialView <iframe src=''></iframe>渲染的局部视图有自己的JavaScript代码和CSS工作表.我尝试了两种方法来完成这项工作(它们都没有工作):
Run Code Online (Sandbox Code Playgroud)1) <iframe src="http://localhost:54351/Box/19"></iframe> public PartialViewResult Box(int id) { return PartialView(GetBox(id)); }结果:纯文本(字符串),没有CSS表格,JavaScript代码不起作用
====================================
2)
Run Code Online (Sandbox Code Playgroud)<iframe src="@{ Html.RenderPartial("~/Views/Box.cshtml", @Model); }"></iframe>结果:显然它不起作用,iframe内没有任何显示
在第一个解决方案中,我想知道是否有可能返回可能具有有效JavaScript代码和CSS表的RazorView对象(或其他东西).有任何想法吗 ?
我有那个代码:
myDataGrid是传递给方法的对象.我知道它是OvserveableCollection不同类型的类型.我只需要将该对象转换为OvserveableCollection<T>(它实现IEnumerable接口)
//get element's type
Type entryType = (myDataGrid as IEnumerable).AsQueryable().ElementType;
foreach (var item in (IEnumerable<entryType>)myDataGrid)
{}
Run Code Online (Sandbox Code Playgroud)
但是编译器不知道entryType循环头中的内容.为什么?
我的表格中的每一行都有一些复选框.每个复选框都有,name='myName'因为我想在每行中只选择一个复选框.但是我错过了一些东西,因为我能够检查所有这些:

但我想要那个结果:

我在这里想念的是什么?
我尝试在SessionFactory中启用Bach大小:
Fluently.Configure()
.Database(MySQLConfiguration.Standard.AdoNetBatchSize(1)
.ConnectionString("xxx"))
.Mappings(m => m.FluentMappings.AddFromAssembly(...))
.ExposeConfiguration(c => c.SetProperty("adonet.batch_size", "1"))
.BuildSessionFactory();
Run Code Online (Sandbox Code Playgroud)
但是当我想设置批量大小的值时:
Session = _sessionFactory.OpenSession();
Session.SetBatchSize(25);
Session.FlushMode = FlushMode.Commit;
Run Code Online (Sandbox Code Playgroud)
我仍然得到那个错误:
没有为会话工厂定义批量大小,禁用批处理.设置adonet.batch_size = 1以启用批处理.
我使用Castle Windsor作为DI机制,我被困在这里.我使用构造函数注入类型,它工作正常.
但是,当我声明一些其他类的构造函数时,我需要调用默认构造函数,在那里发生DI魔术.
所以,我有以下代码:
private readonly IUserService UserService = null;
public CustomAccessAttribute(IUserService userService)
{
this.UserService = userService;
}
public CustomAccessAttribute(bool someParam) : this() //here I'd like to call the above constructor
{
....
}
Run Code Online (Sandbox Code Playgroud)
但我得到了错误
构造函数'CustomAccessAttribute.CustomAccessAttribute(bool)'无法调用自身
我不想把userService对象放在this()调用中,因为DI容器应该这样做.那么,我该如何解决这个错误呢?
这是一个简单的代码:
var w = Utilities.MillimetersToPoints(420);
var h = Utilities.MillimetersToPoints(210);
var doc1 = new Document(new Rectangle(w, h));
PdfWriter writer = PdfWriter.GetInstance(doc1, new FileStream("Doc1.pdf", FileMode.Create));
doc1.Open();
PdfContentByte cb = writer.DirectContent;
var rect = new Rectangle(200, 200, 100, 100);
Run Code Online (Sandbox Code Playgroud)
现在,如果我执行以下操作:
cb.Rectangle(200, 200, 100, 100);
cb.Stroke();
Run Code Online (Sandbox Code Playgroud)
然后我看到了矩形。但我需要设置它的边框宽度,所以我做
rect.BorderWidth = 5;
rect.BorderColor = new BaseColor(0,0,0);
cb.Rectangle(rect);
cb.Stroke();
Run Code Online (Sandbox Code Playgroud)
现在矩形不可见。为什么 ?