创建 SQL 数据源

发布于 2024-09-01 10:11:55 字数 435 浏览 4 评论 0原文

我有一个表 (EmployeeID,EmployeeName,ManagerID) 如何创建 SQLDataSource 来包含 ManagerName 来自 EmployeeName 给定的 EmployeeID = ManagerID?在我的 GridView 中,拖动 DropDownList 后,我应该执行什么绑定来显示 ManagerName?是否可以在不编写自定义 SELECTINSERTDELETEUPDATE 的情况下使用它?如果不是,我需要执行哪些步骤来编写整个内容,即自定义网格和源?

I have a table (EmployeeID,EmployeeName,ManagerID) How can I create a SQLDataSource to include the ManagerName from the EmployeeName given EmployeeID = ManagerID? In my GridView after dragging a DropDownList what bindings should I do to display the ManagerName? Is it possible to use it without writing custom SELECT, INSERT, DELETE or UPDATE? If not what are the steps I need to do to write the whole thing i.e. custom grid and source?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执手闯天涯 2024-09-08 10:11:55

SQL 数据源控件仅允许您轻松地将 ASP.NET 数据绑定控件连接到数据源。您仍然需要编写正确的 SQL 来执行相关连接并获取所需的数据。例如,您必须编写一个 sql 命令,如下所示:

SELECT EmployeeTable.EmployeeName, ManagerTable.ManagerName
FROM EmployeeTable
INNER JOIN ManagerTable ON EmployeeTable.ManagerID=ManagerTable.ManagerID
WHERE EmplyeeTable.EmployeeID = @EmployeeID

SQL datasource controls just allow you to easily wire up asp.net databound controls to datasources. You still have to write the correct SQL to do the relevent joins and get the data you require. e.g. you would have to write a sql commaind something like:

SELECT EmployeeTable.EmployeeName, ManagerTable.ManagerName
FROM EmployeeTable
INNER JOIN ManagerTable ON EmployeeTable.ManagerID=ManagerTable.ManagerID
WHERE EmplyeeTable.EmployeeID = @EmployeeID
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文