2011-03-10 116 views

回答

0

確定Visual Studio 2008爲我提供了額外的菜單,並且它不在視圖中,而是在主菜單中。

謝謝你們的幫助。

帕烏

1
var data = new Appointment[] {...}; 
// or 
var data = from ... where ... select...; 

ReportDataSource rds = new ReportDataSource(); 
rds.Name = "Appointments"; 
rds.Value = data; 

localReport.DataSources.Add(rds); 

你可以使用任何DataTableIEnumerableBindingSourceSystem.Web.UI.IDataSourceReportDataSource的(在data變量在此示例中)的值。

RDL定義看起來與數據庫數據相同。相反,在數據集定義的數據庫列,將有對象的屬性:

<DataSets> 
    <DataSet Name="Appointments"> 
     <Fields> 
      <Field Name="Id"> 
       <DataField>Id</DataField> 
      </Field> 
      <Field Name="Name"> 
       <DataField>Name</DataField> 
      </Field> 
     </Fields> 
     <Query> 
      <DataSourceName>ds</DataSourceName> 
      <CommandText>Appointments</CommandText> 
     </Query> 
    </DataSet> 
</DataSets> 
1

您可以使用此代碼:

代碼背後:

   Dataset dataSet = new Dataset(); 
       ReportViewer1.Visible = true; 
     var emp = new HistoryEntity();  --------------->>> this is my Entity Class 
       emp.DateFrom = '2/2/2011'; 
       emp.DateTo = '2/3/2011'; 


       //sqlcon/command/Create Select etch...use datadapter and fill to dataSet 



       var datasource = new ReportDataSource("CreatedDataset", dataSet.Tables[0]); 
       ReportViewer1.LocalReport.DataSources.Clear(); 
       ReportViewer1.LocalReport.DataSources.Add(datasource); 
       if (dataSet.Tables[0].Rows.Count == 0) 
       { 
        WebMessageBox.Show("Sorry,No Records found"); 
       } 
       ReportViewer1.LocalReport.Refresh(); 

ASP頁:

<rsweb:ReportViewer ID="ReportViewer1" runat="server" 
          Width="1230px" Font-Names="Verdana" Font-Size="8pt" Height="400px" 
            Visible="False"> 
            <LocalReport ReportPath="History.rdlc"> 
            </LocalReport> 
         </rsweb:ReportViewer> 

我在我的網絡應用程序本地報告(rdlc)中使用這個

Regards

+0

是的,我得到這個日Thnx,但你如何在報告本身,報告分配到數據網格?在VS2010中,我可以將數據源分配爲對象,但我無法在VS2008中找到相同的選項 – cpoDesign 2011-03-11 08:00:37

+0

您是什麼意思將報告的結果綁定到數據網格?或許您需要使用dataGrid.datasource = dataSet dataGrid.databind() 。我的帖子是否可以幫助你處理你的第一篇文章(接受答案)。問候 – Crimsonland 2011-03-11 08:21:20