从数据库中选择,从项目中制作图标
当我从树视图中选择某些内容时,它会将一个参数传递给 linq 命令,该命令从数据库中选择一些数据。对于选择中的每个项目,我想制作一个图标和一个文本来表示该项目是文件夹还是文件。 当我推送图标或链接时,我希望它执行与推送树视图相同的操作,将参数传递给 linq 命令,该命令再次从数据库中选择并填充占位符。
我现在这样做的方法是在 runtima 中制作一个包含 ImageButton 和 LinkButton 的面板。然后我将面板添加到 ContentPlaceHolder。 问题在于,每次我选择新内容时它都会执行此操作,而且如果按下图标或链接按钮(仅从树视图中按下图标或链接按钮),我也无法使其工作。
我可以使用一些控制器和 CSS 来获得图标的外观吗? 还有其他更好的方法吗?
这与 Windows 中的资源管理器使用的系统基本相同,树视图仅显示文件夹,但窗口显示文件夹和文件。当我单击一个文件夹时,该文件夹将打开,主窗口中将填充该文件夹内的项目。如果我单击一个文件,编辑器将打开并显示该文件的内容。
What I'm trying to do is basicly what this photo shows.
When I select something from the treeview it passes a parameter to a linq command that selects some data from the database. For every item in the selection I want to make a Icon and a text that represents if the item is a folder or a file.
When I push the Icon or the Link i want it to do the same as i would push the treeview, pass a parameter to a linq command that selects again from the database and populates the placeholder.
The way I'm doing this now is to make at runtima a Panel that holds the ImageButton and LinkButton. Then i add the Panel to the ContentPlaceHolder.
The problem with this that it does it every time i select something new and also i cant get it to work if the push the icon or the linkbutton, only the from the treeview.
Could i use some controller and css to get this look for the Icons ?
Is there another better way ?
This is basicly the same system as the Explorer uses in Windows, Treeview shows only the folder but the window shows the folders and files. When i click a folder that folder opens up and the main window is populated with items that are inside that folder. If i click a file a editor opens up with the contents of the file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定我是否 100% 理解你的问题,但我想我明白了要点。
我假设您首先需要文件夹,然后是文件。我将在此区域中创建两个中继器,一个用于保存文件夹图像和链接按钮,另一个用于文件图像和链接按钮。
将 linq 命令分解为两个查询,一个用于获取文件夹,另一个用于获取文件。然后只需将中继器绑定到相应的中继器即可。
下面是一些可以帮助您入门的代码:
调用
DataBind()
后的代码:显然,您可以使用 Click 事件执行任何您想要的操作,只需将这些添加到其中即可。
我可能会创建一个文件夹和文件控件并使用它们而不是图像按钮/链接按钮组合,这样我就可以存储有关文件夹/文件的更多信息以便稍后访问它们,而无需执行另一个查询来获取 ID 或其他内容。但有一百万种方法,选择你认为最好的一种。
如果您需要此解决方案的更多指导,或者我不明白您的问题,请告诉我。
快乐编码...
Not sure I understand you question 100% but I think I got the gist.
I'm assuming that you want the folders first, then the files. I would create two repeaters in this area, one to hold the Folder Image and link buttons, and the other for the file image and link buttons.
Break your linq command into two queries, one to get the folders and one for files. Then just bind the repeaters to the corresponding repeaters.
Here's a bit of code to get you started:
And the code behind after calling
DataBind()
:You can obviously do whatever you want with Click Events, just added those in for good measure.
I would probably create a Folder and File Control and use those instead of the imagebutton / linkbutton combo, this way I could store more information about the Folder / File to access them later without having to do another query to get the ID or what not. But there are a million approaches to this, pick the one you think is best.
Let me know if you need more guidance w/ this solution, or if I didn't understand your question.
Happy Coding...
抱歉,必须添加为另一个答案。下面是文件夹用户控件的快速示例。
创建您的控件...按照您想要的格式。
将属性和单击事件添加到后面的代码中(不要忘记在单击图像和链接按钮时触发单击事件):
创建文件夹按钮控件的转发器:
在数据绑定上设置文件夹 ID:
最后,您可以执行任何操作想了解该活动请点击:
如果有任何不清楚的地方,请告诉我。这只是一个快速徒手示例,因此请原谅任何拼写错误或不良做法...代码仅用于演示目的。
Sorry had to add as another Answer. Here's a quick sample of the folder user control.
Create your Control... Format however you want.
Add Properties and Click Event to the Code Behind (don't forget to fire the click event when your image and link buttons are clicked):
Create your Repeater of the FolderButton Controls:
Set Folder Id on DataBinding:
Lastly you can then do whever you want on the event Click:
Let me know if anything is unclear. This is just a quick freehand sample, so forgive any typos or bad practices... code is just for demostration purposes only.