Click here to Skip to main content
15,893,722 members
Home / Discussions / Database
   

Database

 
GeneralI dont get it :-) Get Discounted price by porcentage Pin
AlexeiXX327-Mar-08 18:32
AlexeiXX327-Mar-08 18:32 
GeneralRe: I dont get it :-) Get Discounted price by porcentage Pin
Ashfield28-Mar-08 0:50
Ashfield28-Mar-08 0:50 
GeneralRe: I dont get it :-) Get Discounted price by porcentage Pin
Sgg24528-Mar-08 2:21
Sgg24528-Mar-08 2:21 
GeneralRe: I dont get it :-) Get Discounted price by porcentage Pin
AlexeiXX328-Mar-08 9:11
AlexeiXX328-Mar-08 9:11 
GeneralWeird Error Message in MS Access...Please help Pin
new_phoenix27-Mar-08 7:37
new_phoenix27-Mar-08 7:37 
AnswerRe: Weird Error Message in MS Access...Please help Pin
Justin Porteous27-Mar-08 8:54
Justin Porteous27-Mar-08 8:54 
GeneralDatabinding for SSRS CustomReportItem Pin
Mark J. Miller27-Mar-08 7:13
Mark J. Miller27-Mar-08 7:13 
GeneralRe: Databinding for SSRS CustomReportItem Pin
Mark J. Miller27-Mar-08 10:42
Mark J. Miller27-Mar-08 10:42 
Well, I found the solution to the problem. The requirements for using the CustomData property are this:

A) In the CustomReportItemDesigner class (your custom class which inherits from it as a base), override the InitializeNewComponent() method like this:
<br />
public override void InitializeNewComponent()<br />
{<br />
  base.InitializeNewComponent();<br />
<br />
  CustomData = new CustomData();<br />
<br />
  //at least one grouping is required for both rows and columns<br />
<br />
  //initialize a static row grouping<br />
  CustomData.DataRowGroupings = new DataRowGroupings();<br />
  CustomData.DataRowGroupings.DataGroupings = new List<DataGrouping>(1);<br />
  CustomData.DataRowGroupings.DataGroupings.Add(new DataGrouping());<br />
  CustomData.DataRowGroupings.DataGroupings[0].Static = true;<br />
  <br />
  // initialize a Static column grouping<br />
  CustomData.DataColumnGroupings = new DataColumnGroupings();<br />
  CustomData.DataColumnGroupings.DataGroupings = new List<DataGrouping>(1);<br />
  CustomData.DataColumnGroupings.DataGroupings.Add(new DataGrouping());<br />
  CustomData.DataColumnGroupings.DataGroupings[0].Static = true;<br />
<br />
  //initialize data row with empty values for designer<br />
  CustomData.DataRows = new List<DataRow>(1);<br />
  CustomData.DataRows.Add(new DataRow());<br />
  CustomData.DataRows[0].Add(new DataCell());<br />
<br />
  //define the fields you will store (these will be populated with expressions by custom designer properties you define)<br />
  CustomData.DataRows[0][0].Add(new DataValue("Label", String.Empty));<br />
  CustomData.DataRows[0][0].Add(new DataValue("X", String.Empty));<br />
  CustomData.DataRows[0][0].Add(new DataValue("Y", String.Empty));<br />
  }<br />


B) Define custom designer properties to set the expressions for the DataValuesCollection (only showing one property here to keep things shorter)
<br />
[Browsable(true), Category("Data")]<br />
public string XValue<br />
{<br />
	get<br />
	{<br />
		if (CustomData.DataRows.Count > 0 && CustomData.DataRows[0].Count > 0)<br />
			return GetDataValue(CustomData.DataRows[0][0], "X");<br />
		else<br />
			return "X Coordinate";<br />
	}<br />
	set<br />
	{<br />
		SetDataValue(CustomData.DataRows[0][0], "X", value);<br />
	}<br />
}<br />
<br />
<br />
private string GetDataValue(DataCell cell, string name)<br />
{<br />
	foreach (DataValue value in cell)<br />
		if (value.Name == name)<br />
			return value.Value;<br />
	return null;<br />
}<br />
<br />
private void SetDataValue(DataCell cell, string name, string expression)<br />
{<br />
	foreach (DataValue value in cell)<br />
		if (value.Name == name)<br />
		{<br />
			value.Value = expression;<br />
			return;<br />
		}<br />
	DataValue datavalue = new DataValue(name, expression);<br />
	cell.Add(datavalue);<br />
}<br />


C) Make sure your designer provides a property to set the data set name (CustomData.DataSetName).

D) Your CustomReportItem class can then read the data like this:

<br />
private void ReadCustomData()<br />
{	<br />
	DataCellCollection rows = m_CRI.CustomData.DataCells;<br />
<br />
	//get the position of each field in the data value collection<br />
	int xpos = -1, ypos = -1, labelpos = -1;<br />
<br />
	for (int field = 0; field < rows[0, 0].DataValues.Count; field++)<br />
	{<br />
		switch (rows[0, 0].DataValues[field].Name)<br />
		{<br />
			case "X":<br />
				xpos = field;<br />
				break;<br />
			case "Y":<br />
				ypos = field;<br />
				break;<br />
			case "Label":<br />
				labelpos = field;<br />
				break;<br />
		}<br />
	}<br />
<br />
	//populate the series for the chart data<br />
	for (int row = 0; row < rows.RowCount; row++)<br />
	{<br />
		DataValueCollection values = rows[row, 0].DataValues;<br />
		<br />
		double x = Convert.ToDouble(values[xpos].Value);<br />
		double y = Convert.ToDouble(values[ypos].Value);<br />
		string label = (string)values[labelpos].Value;<br />
	}<br />
}<br />


NOTE: This assumes the data in your data set is already grouped and the report does not need to perform any grouping on the data in your dataset.


GeneralDYNAMICALLY Generating Reports in SSRS-2005 Pin
Aswanth26-Mar-08 23:12
Aswanth26-Mar-08 23:12 
GeneralPrefix 'sp' for stored procs Pin
Brady Kelly26-Mar-08 22:47
Brady Kelly26-Mar-08 22:47 
GeneralRe: Prefix 'sp' for stored procs Pin
Jammer27-Mar-08 0:02
Jammer27-Mar-08 0:02 
GeneralRe: Prefix 'sp' for stored procs Pin
Brady Kelly27-Mar-08 0:08
Brady Kelly27-Mar-08 0:08 
GeneralRe: Prefix 'sp' for stored procs Pin
pmarfleet27-Mar-08 0:10
pmarfleet27-Mar-08 0:10 
GeneralRe: Prefix 'sp' for stored procs Pin
Rob Philpott27-Mar-08 3:09
Rob Philpott27-Mar-08 3:09 
GeneralRe: Prefix 'sp' for stored procs Pin
Pete O'Hanlon27-Mar-08 3:16
mvePete O'Hanlon27-Mar-08 3:16 
GeneralRe: Prefix 'sp' for stored procs Pin
pmarfleet27-Mar-08 3:36
pmarfleet27-Mar-08 3:36 
GeneralRe: Prefix 'sp' for stored procs Pin
Brady Kelly27-Mar-08 3:54
Brady Kelly27-Mar-08 3:54 
GeneralRe: Prefix 'sp' for stored procs Pin
Pete O'Hanlon27-Mar-08 3:56
mvePete O'Hanlon27-Mar-08 3:56 
GeneralRe: Prefix 'sp' for stored procs Pin
GuyThiebaut27-Mar-08 0:34
professionalGuyThiebaut27-Mar-08 0:34 
GeneralRe: Prefix 'sp' for stored procs Pin
Pete O'Hanlon27-Mar-08 3:14
mvePete O'Hanlon27-Mar-08 3:14 
GeneralRe: Prefix 'sp' for stored procs Pin
Rob Philpott27-Mar-08 3:56
Rob Philpott27-Mar-08 3:56 
GeneralRe: Prefix 'sp' for stored procs Pin
Christian Graus28-Mar-08 1:53
protectorChristian Graus28-Mar-08 1:53 
GeneralRe: Prefix 'sp' for stored procs Pin
Brady Kelly28-Mar-08 2:16
Brady Kelly28-Mar-08 2:16 
QuestionHow to Report a Change in DB to ApplicationS Pin
half-life26-Mar-08 20:33
half-life26-Mar-08 20:33 
AnswerRe: How to Report a Change in DB to ApplicationS Pin
Ashfield26-Mar-08 21:14
Ashfield26-Mar-08 21:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.