如何从组合框选择项目并在数据网格视图中查看 [英] How to select item from combo box and view in data grid view

查看:60
本文介绍了如何从组合框选择项目并在数据网格视图中查看的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


朋友

我正在使用Visual Studio 2008窗口应用程序和sql server2005 express

我使用了一个组合框,并且使用了数据绑定项
我希望如果用户从组合框中选择项目,则数据应在数据网格"视图中查看

例如:组合框包含用户名,例如ram sham等,
如果用户选择名称ram
因此,在数据网格视图中,它应该显示ram购买的产品,例如产品名称(文本框),折扣类型(文本框).
然后在同一个数据网格视图中,我放置了两个文本框,以便用户可以手动设置折扣和手动设置条件

还有一件事,在SQL中有两个不同的表,我想加入它们,它们之间没有关系,但是我想在选择组合框时应该在数据网格中查看:(



以及如何调整数据网格视图列

在Advance中致谢

Hi
Friend

I am using Visual Studio 2008 window application and sql server2005 express

i have use one combo box and in that i have used Data bound item
i want that if user select the item from combo box then data should view in the Data Grid view

For ex : Combo box contain User name like ram sham so on
if user select the name ram
so in data grid view it should show what ram has buy like product name(Text box) , discount type(Text box).
then in same data grid view i have put two text box so the user can put the discount manually and condition manually

One more thing there are two different table in sql and i want to join them and there is no relation between them but i want on the selection of the combo box it should view in data grid :(



and how can i adjust the data grid view column

Thanks in Advance

推荐答案

放置组合框,并将求和字段添加到其中.从组合框中选择事件,您应该将选定的项目名称分配给会话密钥,然后在页面中放置数据网格视图.使用该数据网格属性,您必须选择数据源并建立与网格相关的连接字符串.

从连接字符串中,选择where子句,并指向会话变量,在该变量中,您从组合框中分配了值.然后保存设置并运行它将起作用的页面,

如果您同意以上答案,请按接受答案或对该答案投赞成票..

一切顺利.
place combo box and add sum fields into it. from the combo box selected event u should assign a selected item name into session key then u place a data grid view in ur page. with that data grid property u have to select data source and make a connection string related to the grid.

from the connection string u select the where clause and pointed to session variable in which u assigned the value from combo box.. then save the settings and run the page it will work,,

if u agreed above the above answer press accept answer or put vote for this answer..

all the best..


Arti,
根据您在组合框中选择的值绑定网格视图非常简单.

在组合框的SelectedIndexChangedEvent()中,编写SQL查询以绑定gridview.
例如

Hi Arti,
its very simple to bind the gridview based ont the value u have selected in the combobox.

In the SelectedIndexChangedEvent() of your combobox, write your SQL Query to bind the gridview.
For e.g.

 protected void ComboBox_SelectedIndexChanged(object o, xSelectedIndexChangedEventArgs e)
{
    int Value=Convert.ToInt32(ComboBox.SelectedValue);
    
    //  Now Pass this int Value to your SQL query to fetch the records of THAT Value, and bind your grid.
   // Grid.DataSource=ds.Tables[0];   
}



希望对您有所帮助.
如有疑问,请回复我.
或者,您可以通过 lokesh.zende@xecomit.com



I hope it will help.
If any query, pls revert back to me.
Or you can contact me on lokesh.zende@xecomit.com


这篇关于如何从组合框选择项目并在数据网格视图中查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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