combox事件已更改 [英] combox event changed

查看:82
本文介绍了combox事件已更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个绑定到数据库的组合框,当我从组合框选择订单时,
它必须在单独的gridviews上显示OrderDetails和Customer Dfetails.我实现了,现在我希望在选择All时在该组合框中有一个"All"选项,它显示数据库中的所有orderDetails和Customer Details.注意,我得到的表是orderDetails和Customer Details他们从Orders table.In有外键.我使用外键检索数据,但是现在选项ALL没有外键,这就是我面临的问题

我的选择组合框绑定代码

Hi
I got a combobox that I bind to database and when I select a order from combobox
it must display OrderDetails and Customer Dfetails on seperate gridviews i achieved that now i want to have an "All" option in that combobox when ALL is selected it display all ordersDetails and Customer Details from database.Note I got tables which are ordersDetails and Customer Details they have foreign key from Orders table.I retrieve data using a foreign key but now option ALL doesnt have foreign key thats the problem that i am facing

My code for select combobox binding

SELECT [ID],
[orderName] ,
from
Orders



我的gridview选择代码,根据从组合框选择的内容在gridview上显示选定的项目



my gridview select code that display selected item on gridview according to what is selected from combobox

SELECT CustomerName,CustomerName,

FROM Orders inner join OrderDetails on Orders .ID = OrderDetails .orderRef
WHERE ID = @.orderRef

推荐答案

对于所有语句,无需条件
它将显示所有数据.
不需要外键.

就像...

SELECT CustomerName,CustomerName,
FROM订单内部联接Orders上的OrderDetails .ID = OrderDetails.orderRef

尝试.........
For all statement don''t need to Where Condition
It will show all data.
No need to foreign key.

Like as...

SELECT CustomerName,CustomerName,
FROM Orders inner join OrderDetails on Orders .ID = OrderDetails.orderRef

Try...........


嗨 你可以试试看,

hi you can try this ,

<asp:GridView ID="grd" runat="server" CaptionAlign="Top" Width="100%" SelectedIndex="0" CellPadding="4"

                   AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"

                              GridLines="Vertical" ForeColor="Black">
                  <Columns>

                      <asp:TemplateField HeaderText="Select Record">
                          <ItemTemplate>
                           put controls here like:
  <asp:label id="lblLabel" runat="server" text="<%# Bind("tableColumn") %>" xmlns:asp="#unknown"></asp:label>
                              </ItemTemplate>
                      </asp:TemplateField>
</Columns>


在两个表上应用联接查询会将结果分配到一些具有所有数据结果的dataTable中.
将其分配给grd.DataSource并调用grd.DataBind();

这是将查询结果的列绑定到gridview的一种方法.
或者,您也可以检索连接结果并仅使用以下逻辑.

一些DataTable object =您的联接查询结果; //或者您也可以使用dataAdapter和Dataset
grd.DataSource =某个表;
grd.DataBind()


Apply join query on both tables assign the result into some dataTable which is having result of all data.
assign it to grd.DataSource and call grd.DataBind();

this will be the one way where you can bind the columns of query result to the gridview...
Or you can retreive join result and simply use following logic.

some DataTable object=result of your join query; //or you can use dataAdapter and Dataset also
grd.DataSource=some table;
grd.DataBind()


这篇关于combox事件已更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆