I have a DataGrid.I binded ObservableCollection to DataGrid.I added paging to it.
For it I converted ObservationCollection into DataTable.
My code is as
ObservableCollection<RiskSettings> riskCollection = new ObservableCollection<RiskSettings>();
grdRiskAlerts.DataContext = riskCollection;
dTable = ToDataTable(riskCollection);
object[] obj = gridPaging.CustomPaging(dTable, (int)DataGridPaging.PagingMode.First);
grdRiskAlerts.ItemsSource = (DataView)obj[0];
txtDispRecs.Text = obj[1].ToString();
txtNumOfPages.Text = obj[2].ToString();
txtTotalRecs.Text = "Total : " + dTable.Rows.Count;
if (dTable.Rows.Count <= recPerPage)
{
brdPaging.IsEnabled = false;
}
else
brdPaging.IsEnabled = true;
My Class name is RiskSettings.
When i right Click on selected row,did operation Type Casting problem is arising.
So i need to bind Datagrid with class instead of (DataView)obj[0]
How to do it?
I tried it,But unable to find solution
Can any help on this?
Thanks in advance,
Ramki.
Related
I am modifying the SalesConfirmDP class and trying to add the CustVendExternalItem.ExternalItemTxt field into a new field I have created.
I have tried a couple of things but I do not think my syntax was correct i.e I declare the CustVendExternalItem table in the class declaration. But then when I try to insert CustVendExternalItem.ExternalItemTxt into my new field, it does not populate, I guess there must be a method which I need to include?
If anyone has any suggestion it would be highly appreciated.
Thank you in advance.
private void setSalesConfirmDetailsTmp(NoYes _confirmTransOrTaxTrans)
{
DocuRefSearch docuRefSearch;
// Body
salesConfirmTmp.JournalRecId = custConfirmJour.RecId;
if(_confirmTransOrTaxTrans == NoYes::Yes)
{
if (printLineHeader)
{
salesConfirmTmp.LineHeader = custConfirmTrans.LineHeader;
}
else
{
salesConfirmTmp.LineHeader = '';
}
salesConfirmTmp.ItemId = this.itemId();
salesConfirmTmp.Name = custConfirmTrans.Name;
salesConfirmTmp.Qty = custConfirmTrans.Qty;
salesConfirmTmp.SalesUnitTxt = custConfirmTrans.salesUnitTxt();
salesConfirmTmp.SalesPrice = custConfirmTrans.SalesPrice;
salesConfirmTmp.DlvDate = custConfirmTrans.DlvDate;
salesConfirmTmp.DiscPercent = custConfirmTrans.DiscPercent;
salesConfirmTmp.DiscAmount = custConfirmTrans.DiscAmount;
salesConfirmTmp.LineAmount = custConfirmTrans.LineAmount;
salesConfirmTmp.CurrencyCode = custConfirmJour.CurrencyCode;
salesConfirmTmp.PrintCode = custConfirmTrans.TaxWriteCode;
if (pdsCWEnabled)
{
salesConfirmTmp.PdsCWUnitId = custConfirmTrans.pdsCWUnitId();
salesConfirmTmp.PdsCWQty = custConfirmTrans.PdsCWQty;
}
**salesConfirmTmp.ExternalItemText = CustVendExternalItem.ExternalItemTxt;**
if ((custFormletterDocument.DocuOnConfirm == DocuOnFormular::Line)
|| (custFormletterDocument.DocuOnConfirm == DocuOnFormular::All))
{
docuRefSearch = DocuRefSearch::newTypeIdAndRestriction(custConfirmTrans,
custFormletterDocument.DocuTypeConfirm,
DocuRestriction::External);
salesConfirmTmp.Notes = Docu::concatDocuRefNotes(docuRefSearch);
}
salesConfirmTmp.InventDimPrint = this.printDimHistory();
Well, AX cannot guess which record you need, there is a helper class CustVendExternalItemDescription to deal with it:
boolean found;
str externalItemId;
...
[found, externalItemId, salesConfirmTmp.ExternalItemText] = CustVendExternalItemDescription::findExternalItemDescription(
ModuleCustVend::Cust,
custConfirmTrans.ItemId,
custConfirmTrans.inventDim(),
custConfirmJour.OrderAccount,
CustTable::find(custConfirmJour.OrderAccount).CustItemGroupId);
The findExternalItemDescription method returns more information than you need here, but you have to define variables to store it anyway.
Well, the steps to solve this problem are fairly easy and i will try to give you a step by step approach how to solve this problem.
1) Are you initialising CustVendExternalItem properly? Make a record of the same and initialise it as Jan has shown above, then debug your code and see if the value is being initialised in your DP class.
2)If your value is being initialised correctly, but it is not showing up in the report design there can be multiple issues such as:
Overlapping of text boxes.
Insufficient space for the given field
Some report parameter/property not being set correctly which causes
your value not to show up on the report.
Check these one by one and you should end up arriving towards a solution
I need to format the label inside the BarItem so it can have a time format, like 00:10.
I'm using the BarSeries.Format function, but if I don't use the BarSeries.LabelFormatString the labels don't show and if I use LabelFormatString all labels will have the same format/values.
Here's my code:
BarItem baritem = new BarItem {Value = 10}; //in seconds
Object[] time = new object[2];
time [0] = "00";
time [1] = "10";
barSeries.Format("{0}:{1}",baritem,time);
With this code it shows no labels. Using barSeries.LabelFormatString = "{0}" shows 10.
I've tried barSeries.LabelFormatString = barSeries.Format("{0}:{1}",baritem,time) but then all labels became the same...
For someone that had the same problem, the solution is simple, just subclass the BarItem Class, like this:
class TimeBarItem : BarItem {
public TimeSpan Time { get { return TimeSpan.FromSeconds(this.Value); } }
}
After that we can do:
barSeries.LabelFormatString = "{Time}"
I am developing a view page.
Here is my code:
int idses = Convert.ToInt32(Session["ID"].ToString());
// address
DataTable adrDT = new DataTable();
adrDT = ClassView.GetRows(idses);
houseN.Text = adrDT.Rows[0]["houseN"].ToString();
streetAD.Text = adrDT.Rows[0]["stAddress"].ToString();
townAD.Text = adrDT.Rows[0]["town"].ToString();
cityAD.Text = adrDT.Rows[0]["city"].ToString();
stateAD.Text = adrDT.Rows[0]["state"].ToString();
zipC.Text = adrDT.Rows[0]["zipCOde"].ToString();
ddlC.SelectedValue = adrDT.Rows[0]["countryID"].ToString();
teleNumb.Text = adrDT.Rows[0]["telephoneN"].ToString();
faxNumb.Text = adrDT.Rows[0]["faxN"].ToString();
this the code in my datalayer:
string rowSQL = "SELECT Merchant_Master.id, Merchant_Master.CompanyName, Merchant_Master.Url, Merchant_Master.AddressID, Industry.IndustryName, "
+ "Merchant_Master.IsActive, Merchant_Master.IsDeleted, Merchant_Master.DateCreated "
+ "FROM Merchant_Master JOIN Industry on Merchant_Master.IndustryID = Industry.id where Merchant_Master.id = #id";
//string rowSQL = "SELECT CompanyName, Url, DateCreated FROM Merchant_Master";
string[] param = {"#id"};
object[] paramVal = {};
return ClassDBQuery.ExecDataReader(rowSQL, param, paramVal);
My question is: How will I call the #id in the code behind?
adrDT = ClassView.GetRows(idses); -> in this line...when I put idses, I get the error "No overload for method 'GetRows()' takes one argument"... What should I do?
This means that, on your ClassView class, you dont have a GetRows method expecting any parameter. Look your ClassView again.
EDIT:
If the type of idses is int, you should do:
public static DataTable GetRows(int ideses) {...}
I'm trying to create a form that has two tabs, each with a DataGrid with a different filter on it. I've created the filters as such:
ObservableCollection<ParcelVoucherDetails> _voucherDetails = new ObservableCollection<ParcelVoucherDetails>();
CollectionView cvFreightOut = new CollectionView(_voucherDetails);
cvFreightOut.Filter += FreightOutFilter;
dgFreightOut.ItemsSource = cvFreightOut;
CollectionView cvFreightIn = new CollectionView(_voucherDetails);
cvFreightIn.Filter += FreightInFilter;
dgFreightIn.ItemsSource = cvFreightIn;
I then created the filters as such:
public bool FreightOutFilter(object o)
{
ParcelVoucherDetails p = o as ParcelVoucherDetails;
if (p != null)
{
return (p.Type == "Freight Out");
}
return false;
}
public bool FreightInFilter(object o)
{
ParcelVoucherDetails p = o as ParcelVoucherDetails;
if (p != null)
{
return (p.Type == "Freight In");
}
return false;
}
Now, here's where it gets annoying. During a later event, when I add items to the ObservableCollection, I can see the filters firing and accepting or denying the filter as expected, but ALL the items still appear on both DataGrids.
I've tried using CollectionViewSource, and that also doesn't work. The only way I can get any filtering to work at all is to skip the ObservableCollection and use a DataTable with DataViews. I'd like to avoid that here, because of the convenience in the rest of the code for using the ObservableCollection.
Has anyone seen this actually work, and if so, how?
I finally found it after banging my head on the wall. I feel ridiculous right now, but I had to share the solution:
ListCollectionView cvFO = new ListCollectionView(_voucherDetails);
cvFO.Filter += FreightOutFilter;
dgFreightOut.ItemsSource = cvFO;
ListCollectionView cvFI = new ListCollectionView(_voucherDetails);
cvFI.Filter += FreightInFilter;
dgFreightIn.ItemsSource = cvFI;
This sets the filters separately. Apparently, using a generic CollectionView instead of a ListCollectionView is a no-no. :)
I'm writing a custom web part that need to use a couple of rich text box controls. I'm placing the controls onto the web part programatically. When the web part gets a save postback I'm able to capture the data from all the fields except the two rich text box ones. What's the trick to be able to get the value of a rich text box?
The code I"m using to place my form controls is:
private void CreateInputControls()
{
inputPanel.Controls.Clear();
SPList list = SPContext.Current.Site.RootWeb.Lists["MyList"];
SPContentType cType = list.ContentTypes[0];
Table table = new Table();
table.CellPadding = 3;
table.CellSpacing = 0;
SPContext newContext = SPContext.GetContext(System.Web.HttpContext.Current, list.DefaultView.ID, list.ID, list.ParentWeb);
foreach (SPField field in cType.Fields)
{
if (!field.Hidden && field.CanBeDisplayedInEditForm)
{
FieldLabel fieldLabel = new FieldLabel();
fieldLabel.ControlMode = SPControlMode.New;
fieldLabel.ListId = list.ID;
fieldLabel.FieldName = field.InternalName;
fieldLabel.ItemContext = newContext;
fieldLabel.RenderContext = newContext;
fieldLabel.Field.Required = fieldLabel.Field.Required;
FormField formField = new FormField();
formField.ControlMode = SPControlMode.New;
formField.ListId = list.ID;
formField.FieldName = field.InternalName;
formField.ItemContext = newContext;
formField.RenderContext = newContext;
formField.ID = field.InternalName;
formField.EnableViewState = true;
TableRow row = new TableRow();
table.Rows.Add(row);
TableCell cellLabel = new TableCell();
TableCell cellField = new TableCell();
cellLabel.Controls.Add(fieldLabel);
cellField.Controls.Add(formField);
row.Cells.Add(cellLabel);
row.Cells.Add(cellField);
}
}
inputPanel.Controls.Add(table);
}
The code I'm using to save a new item is:
private void UpdateItem(string bannerImageURL, string thumbnailImageURL)
{
SPList list = SPContext.Current.Site.RootWeb.Lists["MyList"];
SPContentType cType = list.ContentTypes[0];
SPItem item = list.AddItem();
foreach (SPField field in cType.Fields)
{
if (!field.Hidden && field.CanBeDisplayedInEditForm)
{
FormField formField = (FormField)inputPanel.FindControl(field.InternalName);
if (formField != null)
{
// Saves data for all fields EXCEPT for rich text box (sharepoint multiline columns).
item[field.Title] = formField.Value;
}
}
}
item.Update();
}
Maybe there's an issue with the field name. Try to use the InternalName.
item[field.InternalName] = formField.Value;
I have been struggling with this and am using a workaround which I thought I'd post as this was quite frustrating.
The problem is that the RTE control is rendered empty and then populated from a hidden control with JavaScript on the client. However this hidden control is accessible server side thus:
switch (formField.Field.Type)
{
case SPFieldType.Note:
var rtf = (RichTextField)formField.Controls[0];
item[field.Title] = rtf.HiddenInput.Value;
break;
default:
item[field.Title] = formField.Value;
break;
}
This may need extending for other field types but you get the idea...