从数据集中显示DatagridView中的数据 [英] Displaying Data in DatagridView from a Dataset

查看:74
本文介绍了从数据集中显示DatagridView中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请协助。我目前正在使用Web服务访问数据库,该数据库包含我想要在datagridview中显示的信息。用户将从组合框中选择输入,然后通过单击按钮,与输入相关的数据将显示在网格视图中。以下是用户将选择广告系列名称的按钮下方的代码,在选择广告系列名称后,他们将点击一个按钮,该按钮必须在datagriview上填充广告系列详细信息。 QueServiceGetCampaignDetails方法位于服务中,我将广告系列ID作为输入传递。当我点击按钮时,没有任何内容被显示。

Please assist. I am currently using a webservice to access a database that has information that I want display in a datagridview. The user will select input from a combo box and then by a click of a button, data that relates to the input will be displayed in a gridview. Below is code that is under the button where a user will select a campaign name, after selecting the campaign name then they will click a button which will have to populate the campaign details on datagriview. The method QueServiceGetCampaignDetails is sitting in a service and I pass the campaign ID as input. When I click the button nothing gets dislayed.

private void btnLoad_Click(object sender, EventArgs e)
{
        Int32 CampaignID = cboSalesPerLead.SelectedIndex;
            
        QueueServiceData _QueueServiceData = new QueueServiceData();

        DataSet ds = new DataSet();

        ds = _QueueServiceData.QueServiceGetCampaignDetails(CampaignID);
        drgvCampaignDetails.DataSource = ds;
                     
}

推荐答案

您目前在哪里
drgvCampaignDetails.DataSource = ds;

尝试定义您想要的表格...例如

try defining which table you want ... e.g.

drgvCampaignDetails.DataSource = ds.Tables[0];


Int32 CampaignID = cboSalesPerLead.SelectedIndex;



你应该在这里传递selectedvalue,而不是选定的指数。

试试

Int32 CampaignID = cboSalesPerLead.selectedvalue;
Int32 CampaignID = cboSalesPerLead.SelectedIndex;

you should pass the selectedvalue here, not the selected index.
try
Int32 CampaignID = cboSalesPerLead.selectedvalue;


这篇关于从数据集中显示DatagridView中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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