|
Well the documentation is dated Jun 2017 and the WSDL file is dated Dec 2007. So this WSDL was current as of VS2010.
Guess I'll toss it in the scrape pile and go back to XML or try the JSON version.
If it ain't broke don't fix it
|
|
|
|
|
It works!
The message "An exception has been raised as a result of client data" basically means that something as dumb as having the country code in the postal code field will crash the UPS Web Service and return this error message.
So I spent the day firing up the sample code from UPS written in 2007. Took awhile to upgrade and make code changes but got it to work.
To get the WebReference to work you have to go to proprties and paste in the current location of the WSDL file. Then on the ProcessRate you add
RateService rate = new RateService() { UPSSecurityValue = Security, Url = endpointUrl };
pResult = rate.ProcessRate(pRequest);
Then placed the working code in my new project, and made a Web Reference for the WSDL and debuged the code till it worked. Use the RateService to call the UPS Service and continued to debug until it returned a list of rates.
Then I referenced back to the Service Reference and placed the soap client and binding back and test fired it to produce a list a rates.
using (var client = new ups_rateService.RatePortTypeClient(new BasicHttpBinding(BasicHttpSecurityMode.Transport), new EndpointAddress(endpointUrl)))
{
pResult = client.ProcessRate(Security, pRequest);
}
So yes this old WSDL works in VS2017 just fine as a Service Reference, but it's the UPS server side and SOAP Exception that will mislead you in hunting down your errors.
If it ain't broke don't fix it
|
|
|
|
|
Hi Richard, sorry to call you out but can you please help me on this issue?
I have been stomped by this now for almost 2 days.
I dynamically creating rows for both Repeater1 and Repeater2.
There is a form field called MarineRegNo on Repeater1.
Once a user enters value for this field and clicks the Next button, that value is transferred a form field called aRegNo in Repeater2.
The issue we are having is that if it is just one row, this value is not getting populated in Repeater2.
If there are two rows for instance, the first row in Repeater2 is not getting populated with value for aRegNo. However, the second row is getting populated with values for aRegNo for Repeater2.
I believe the issue lines with SetInitialRow and SetInitialRow2 functions as I think the values are getting overwritten.
Do you have any ideas how I can resolve this?
There is a ton more codes but I think the two functions below are the relevant codes that are causing the problems.
Thanks as usual for your assistance.
<pre> private void SetInitialRow()
{
myMultiView.ActiveViewIndex = 0;
DataTable dt;
if (ViewState["CurrTable"] == null)
{
dt = new DataTable();
DataRow dr = null;
dt.Columns.Add(new DataColumn("ID", typeof(string)));
dt.Columns.Add(new DataColumn("MarineRegNo", typeof(string)));
dt.Columns.Add(new DataColumn("TaxPyrRetdVal", typeof(string)));
dt.Columns.Add(new DataColumn("VesselRegNo", typeof(string)));
dt.Columns.Add(new DataColumn("VesselTaxPyrRetdVal", typeof(string)));
dr = dt.NewRow();
dr["ID"] = 1;
dr["MarineRegNo"] = string.Empty;
dr["TaxPyrRetdVal"] = string.Empty;
dr["VesselRegNo"] = string.Empty;
dr["VesselTaxPyrRetdVal"] = string.Empty;
dt.Rows.Add(dr);
}
else
{
dt = (DataTable)ViewState["CurrTable"];
}
ViewState["CurrTable"] = dt;
if (dt.Rows.Count > 0)
{
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
}
private void SetInitialRow2(string registerNumber, string bregisterNumber)
{
DataTable dts;
if (ViewState["CurrentTable"] == null)
{
dts = new DataTable();
DataRow dr = null;
//Create DataTable columns
dts.Columns.Add(new DataColumn("RowNumber", typeof(string)));
dts.Columns.Add(new DataColumn("boatcnty", typeof(string)));
dts.Columns.Add(new DataColumn("aRegNo", typeof(string)));
dts.Columns.Add(new DataColumn("aMake", typeof(string)));
dts.Columns.Add(new DataColumn("mMake", typeof(string)));
dts.Columns.Add(new DataColumn("ModelNoA", typeof(string)));
dts.Columns.Add(new DataColumn("ModelNoM", typeof(string)));
dts.Columns.Add(new DataColumn("boatYrBuilt", typeof(string)));
dts.Columns.Add(new DataColumn("motorYrBuilt", typeof(string)));
dts.Columns.Add(new DataColumn("blength", typeof(string)));
dts.Columns.Add(new DataColumn("hullmaterial", typeof(string)));
dts.Columns.Add(new DataColumn("mhorsepower", typeof(string)));
dts.Columns.Add(new DataColumn("rdlmhorsepType", typeof(string)));
dts.Columns.Add(new DataColumn("datePurchased", typeof(string)));
dts.Columns.Add(new DataColumn("mdatePurchased", typeof(string)));
dts.Columns.Add(new DataColumn("PurchaseType", typeof(string)));
dts.Columns.Add(new DataColumn("rblmPurchasedType", typeof(string)));
dts.Columns.Add(new DataColumn("PrevOnwerName", typeof(string)));
dts.Columns.Add(new DataColumn("prevAddr", typeof(string)));
dts.Columns.Add(new DataColumn("prevCity", typeof(string)));
dts.Columns.Add(new DataColumn("PrevState", typeof(string)));
dts.Columns.Add(new DataColumn("prevzip", typeof(string)));
dts.Columns.Add(new DataColumn("mPrevOnwerName", typeof(string)));
dts.Columns.Add(new DataColumn("mprevAddr", typeof(string)));
dts.Columns.Add(new DataColumn("mprevCity", typeof(string)));
dts.Columns.Add(new DataColumn("mPrevState", typeof(string)));
dts.Columns.Add(new DataColumn("mprevzip", typeof(string)));
dts.Columns.Add(new DataColumn("buyername", typeof(string)));
dts.Columns.Add(new DataColumn("buyeraddress", typeof(string)));
dts.Columns.Add(new DataColumn("buyercity", typeof(string)));
dts.Columns.Add(new DataColumn("buyerstate", typeof(string)));
dts.Columns.Add(new DataColumn("buyerzip", typeof(string)));
dts.Columns.Add(new DataColumn("datesold", typeof(string)));
dts.Columns.Add(new DataColumn("salePrice", typeof(string)));
dts.Columns.Add(new DataColumn("Description", typeof(string)));
dts.Columns.Add(new DataColumn("mbuyername", typeof(string)));
dts.Columns.Add(new DataColumn("mbuyeraddress", typeof(string)));
dts.Columns.Add(new DataColumn("mbuyercity", typeof(string)));
dts.Columns.Add(new DataColumn("mbuyerstate", typeof(string)));
dts.Columns.Add(new DataColumn("mbuyerzip", typeof(string)));
dts.Columns.Add(new DataColumn("mdatesold", typeof(string)));
dts.Columns.Add(new DataColumn("msalePrice", typeof(string)));
dts.Columns.Add(new DataColumn("mDescription", typeof(string)));
dts.Columns.Add(new DataColumn("boatCost", typeof(string)));
dts.Columns.Add(new DataColumn("motorCost", typeof(string)));
dts.Columns.Add(new DataColumn("rblIssues", typeof(string)));
dts.Columns.Add(new DataColumn("functionalIsses", typeof(string)));
dts.Columns.Add(new DataColumn("mrblIssues", typeof(string)));
dts.Columns.Add(new DataColumn("mfunctionalIsses", typeof(string)));
dts.Columns.Add(new DataColumn("vesseltypeUse", typeof(string)));
dts.Columns.Add(new DataColumn("vesselname", typeof(string)));
dts.Columns.Add(new DataColumn("vessellength", typeof(string)));
dts.Columns.Add(new DataColumn("vesselYrBult", typeof(string)));
dts.Columns.Add(new DataColumn("VesselHullMateria", typeof(string)));
dts.Columns.Add(new DataColumn("vesselhorsepEngine", typeof(string)));
dts.Columns.Add(new DataColumn("coastGuardNumber", typeof(string)));
dts.Columns.Add(new DataColumn("VesselYrPurchased", typeof(string)));
dts.Columns.Add(new DataColumn("PurchasedNew", typeof(string)));
dts.Columns.Add(new DataColumn("VesselPurchaseAmt", typeof(string)));
dts.Columns.Add(new DataColumn("homePort", typeof(string)));
dts.Columns.Add(new DataColumn("whereDocked", typeof(string)));
dts.Columns.Add(new DataColumn("bmequipAccessoryList", typeof(string)));
//Create Row for each columns
dr = dts.NewRow();
dr["RowNumber"] = 1;
dr["boatcnty"] = string.Empty;
dr["aRegNo"] = registerNumber;
dr["aMake"] = string.Empty;
dr["mMake"] = string.Empty;
dr["ModelNoA"] = string.Empty;
dr["ModelNoM"] = string.Empty;
dr["boatYrBuilt"] = string.Empty;
dr["motorYrBuilt"] = string.Empty;
dr["blength"] = string.Empty;
dr["hullmaterial"] = string.Empty;
dr["mhorsepower"] = string.Empty;
dr["rdlmhorsepType"] = string.Empty;
dr["datePurchased"] = string.Empty;
dr["mdatePurchased"] = string.Empty;
dr["PurchaseType"] = string.Empty;
dr["rblmPurchasedType"] = string.Empty;
dr["PrevOnwerName"] = string.Empty;
dr["prevAddr"] = string.Empty;
dr["prevCity"] = string.Empty;
dr["PrevState"] = string.Empty;
dr["prevzip"] = string.Empty;
dr["mPrevOnwerName"] = string.Empty;
dr["mprevAddr"] = string.Empty;
dr["mprevCity"] = string.Empty;
dr["mPrevState"] = string.Empty;
dr["mprevzip"] = string.Empty;
dr["buyername"] = string.Empty;
dr["buyeraddress"] = string.Empty;
dr["buyercity"] = string.Empty;
dr["buyerstate"] = string.Empty;
dr["buyerzip"] = string.Empty;
dr["datesold"] = string.Empty;
dr["salePrice"] = string.Empty;
dr["Description"] = string.Empty;
dr["mbuyername"] = string.Empty;
dr["mbuyeraddress"] = string.Empty;
dr["mbuyercity"] = string.Empty;
dr["mbuyerstate"] = string.Empty;
dr["mbuyerzip"] = string.Empty;
dr["mdatesold"] = string.Empty;
dr["msalePrice"] = string.Empty;
dr["mDescription"] = string.Empty;
dr["boatCost"] = string.Empty;
dr["motorCost"] = string.Empty;
dr["rblIssues"] = string.Empty;
dr["functionalIsses"] = string.Empty;
dr["mrblIssues"] = string.Empty;
dr["mfunctionalIsses"] = string.Empty;
dr["vesseltypeUse"] = string.Empty;
dr["vesselname"] = string.Empty;
dr["vessellength"] = string.Empty;
dr["vesselYrBult"] = string.Empty;
dr["VesselHullMateria"] = string.Empty;
dr["vesselhorsepEngine"] = string.Empty;
dr["coastGuardNumber"] = bregisterNumber;
dr["VesselYrPurchased"] = string.Empty;
dr["PurchasedNew"] = string.Empty;
dr["VesselPurchaseAmt"] = string.Empty;
dr["homePort"] = string.Empty;
dr["whereDocked"] = string.Empty;
dr["bmequipAccessoryList"] = string.Empty;
dts.Rows.Add(dr);
}
else
{
dts = (DataTable)ViewState["CurrentTable"];
}
//Store the DataTable in ViewState for future reference
ViewState["CurrentTable"] = dts;
if (dts.Rows.Count > 0)
{
Repeater2.DataSource = dts;
Repeater2.DataBind();
}
}
|
|
|
|
|
How are the functions called? And how is the value of the field from the first repeater passed to the SetInitialRow2 method?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi Richard,
Sorry I could not respond last night because I didn't have access to my laptop from where I was.
SetInitialRow() is called in page_load() event:
if (!Page.IsPostBack)
{
this.SetInitialRow();
...
...
}
}
SetInitialRow2() is called in populateRecord function:
private void PopulateRecord()
{
foreach (RepeaterItem item in Repeater1.Items)
{
string registerNumber = (item.FindControl("txtboatregNum") as TextBox).Text;
string bregisterNumber = (item.FindControl("cgaurdNumber") as TextBox).Text;
if (item.ItemIndex == 0)
{
this.SetInitialRow2(registerNumber, bregisterNumber);
}
else
{
AddNewRow2(registerNumber, bregisterNumber);
}
foreach (RepeaterItem Item in Repeater2.Items)
{
(Item.FindControl("BtnAdd2") as Button).Visible = Repeater2.Items.Count > 2;
(Item.FindControl("btnDelete2") as Button).Visible = Repeater2.Items.Count > 2;
}
}
}<pre>
which in turn is called by the NEXT button click event:
<pre>protected void OnClickNext(object sender, EventArgs e)
{
int rowIndex = 0;
if (ViewState["CurrTable"] != null)
{
DataTable dtCurrentTable = (DataTable)ViewState["CurrTable"];
if (dtCurrentTable.Rows.Count > 0)
{
for (int i = 1; i <= Repeater1.Items.Count; i++)
{
TextBox tbboatregNum = (TextBox)Repeater1.Items[rowIndex].FindControl("txtboatregNum");
TextBox tbPayerret = (TextBox)Repeater1.Items[rowIndex].FindControl("txtPayerret");
TextBox tbCGvesselNum = (TextBox)Repeater1.Items[rowIndex].FindControl("cgaurdNumber");
TextBox tbCGtaxpayerret = (TextBox)Repeater1.Items[rowIndex].FindControl("cguardreturnedval");
dtCurrentTable.Rows[i - 1]["MarineRegNo"] = tbboatregNum.Text;
dtCurrentTable.Rows[i - 1]["TaxPyrRetdVal"] = tbPayerret.Text;
dtCurrentTable.Rows[i - 1]["VesselRegNo"] = tbCGvesselNum.Text;
dtCurrentTable.Rows[i - 1]["VesselTaxPyrRetdVal"] = tbCGtaxpayerret.Text;
rowIndex++;
}
ViewState["TempData"] = dtCurrentTable;
}
myMultiView.ActiveViewIndex += 1;
if (myMultiView.ActiveViewIndex != 3)
{
PopulateRecord();
}
}
}
So, clicking next is supposed to pass these values from Repeater1 to Repeater2.
There are also some other dependencies like getting the total value of TaxPyrRetdVal and VesselTaxPyrRetdVal but they are not relevant because once Repeater is able
to recognize MarineRegNo and VesselRegNo, the others become visible.
Then there are a couple of stored procedures that populate both SetInitialRow() and SetInitialRow2() datatables.
If you remove SetInitialRow2(), then there is no issues with passing the values from Repeater1 to Repeater2.
Only issue there is that the values for Repeater2 will not be passed, only those two form values, MarineRegNo and VesselRegNo are passed.
I must admit that I didn't do all of these by myself.
It is really very long and complicated code.
If I can figure out a way to check the dt datable table values before binding to Repeater, perhaps this could work.
Also, if I remove the stored procedures, everything will be populated on both repeaters except the two most important iems MarineRegNo and VesselRegNo.
I have been stuck on this now for days and was supposed to be demo'ing this app this morning.
Thanks sir as usual for all your expert assistance.
|
|
|
|
|
I'm not sure I'm following exactly what you're doing, but I'd be inclined to start by tidying up the code:
private DataTable LoadTable1(bool createIfMissing)
{
const string ViewStateKey = "CurrTable";
DataTable dt = ViewState[ViewStateKey] as DataTable;
if (createIfMissing)
{
if (dt == null)
{
dt = new DataTable();
dt.Columns.Add(new DataColumn("ID", typeof(string)));
dt.Columns.Add(new DataColumn("MarineRegNo", typeof(string)));
dt.Columns.Add(new DataColumn("TaxPyrRetdVal", typeof(string)));
dt.Columns.Add(new DataColumn("VesselRegNo", typeof(string)));
dt.Columns.Add(new DataColumn("VesselTaxPyrRetdVal", typeof(string)));
ViewState[ViewStateKey] = dt;
}
if (dt.Rows.Count == 0)
{
DataRow dr = dt.NewRow();
dr["ID"] = 1;
dr["MarineRegNo"] = string.Empty;
dr["TaxPyrRetdVal"] = string.Empty;
dr["VesselRegNo"] = string.Empty;
dr["VesselTaxPyrRetdVal"] = string.Empty;
dt.Rows.Add(dr);
}
}
return dt;
}
private void SetInitialRow()
{
myMultiView.ActiveViewIndex = 0;
DataTable dt = LoadTable1(true);
Repeater1.DataSource = dt;
Repeater1.DataBind();
}
private DataTable LoadTable2(bool createIfMissing)
{
const string ViewStateKey = "CurrentTable";
DataTable dt = ViewState[ViewStateKey] as DataTable;
if (dt == null && createIfMissing)
{
dt = new DataTable();
dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
dt.Columns.Add(new DataColumn("boatcnty", typeof(string)));
dt.Columns.Add(new DataColumn("aRegNo", typeof(string)));
...
ViewState[ViewStateKey] = dt;
}
return dt;
}
private void PopulateRecord(DataTable table1)
{
DataTable table2 = LoadTable2(true);
table2.Rows.Clear();
foreach (DataRow row in table1.Rows)
{
DataRow dr = table2.NewRow();
dr["RowNumber"] = table2.Rows.Count + 1;
dr["aRegNo"] = row["MarineRegNo"];
dr["coastGuardNumber"] = row["VesselRegNo"];
...
table2.Rows.Add(dr);
}
Repeater2.DataSource = table2;
Repeater2.DataBind();
foreach (RepeaterItem item in Repeater2.Items)
{
((Button)item.FindControl("BtnAdd2")).Visible = table2.Rows.Count > 1;
((Button)item.FindControl("btnDelete2")).Visible = table2.Rows.Count > 1;
}
}
protected void OnClickNext(object sender, EventArgs e)
{
DataTable dt = LoadTable1(false);
if (dt != null)
{
if (dt.Rows.Count != 0)
{
int rowIndex = 0;
foreach (RepeaterItem item in Repeater1.Items)
{
switch (item.ItemType)
{
case ListItemType.Item:
case ListItemType.AlternatingItem:
case ListItemType.SelectedItem:
case ListItemType.EditItem:
{
TextBox tbboatregNum = (TextBox)item.FindControl("txtboatregNum");
TextBox tbPayerret = (TextBox)item.FindControl("txtPayerret");
TextBox tbCGvesselNum = (TextBox)item.FindControl("cgaurdNumber");
TextBox tbCGtaxpayerret = (TextBox)item.FindControl("cguardreturnedval");
DataRow row = dt.Rows[rowIndex];
row["MarineRegNo"] = tbboatregNum.Text;
row["TaxPyrRetdVal"] = tbPayerret.Text;
row["VesselRegNo"] = tbCGvesselNum.Text;
row["VesselTaxPyrRetdVal"] = tbCGtaxpayerret.Text;
rowIndex++;
break;
}
}
}
}
myMultiView.ActiveViewIndex += 1;
if (myMultiView.ActiveViewIndex != 3)
{
PopulateRecord(dt);
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 21-Sep-17 13:29pm.
|
|
|
|
|
Thank you very much Richard.
I think I got what you are trying to do but it is complaining about registerNumber assigned to ARegNo and bRegisterNumber assigned to coastGuardNumber.
The reason I am having this issue is because we want out users to be able to enter an account number and populate both Repeater1 and Repeater2 if record exists and the reason we want users to enter an account to populate those controls is because they have to complete a form but the form is too long.
So, we broke the form down into 4 pages with page 4 being preview page.
So, user can complete page one, click a button to save and continue later.
When they come back later, they want to know where they stopped.
I don't know if I am still making sense.
modified 21-Sep-17 13:02pm.
|
|
|
|
|
You'd still need to call SetInitialRow , but you shouldn't need to call SetInitialRow2 .
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am just running into many bugs.
First, registerNumber which is assigned to ARegNo is not being recognized.
bregisterNumber which is assigned to coastGuardNumber is not being recorgnized.
Also, dr["ID"] = 1; on populateRecord function is not being recognized.
Thanks for your help sir.
|
|
|
|
|
Aside from a typo in the LoadTable2 function, where I was using dts instead of dt , there shouldn't be any compiler errors with the code I posted.
The code I posted doesn't contain either registerNumber or bregisterNumber .
And the PopulateRecord method I posted doesn't contain dr["ID"] = 1; anywhere.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
That's true sir but the error came up because I added the rest of the code for SetInitialRow2() unless you asking me to use only the ones you posted.
If so, how do I handle the rest because they are supposed to populate Repeater2 when user enters an account number just like MarineRegNo and the other 3 that came with SetInitialRow()
Here is the complete code for SetInitialRow2(). I posted entire code yesterday.
Thanks so much for all your help.
private void SetInitialRow2(string registerNumber, string bregisterNumber)
{
DataTable dta;
if (ViewState["CurrentTable"] == null)
{
dta = new DataTable();
DataRow dr = null;
dta.Columns.Add(new DataColumn("RowNumber", typeof(string)));
dta.Columns.Add(new DataColumn("boatcnty", typeof(string)));
dta.Columns.Add(new DataColumn("aRegNo", typeof(string)));
dta.Columns.Add(new DataColumn("aMake", typeof(string)));
dta.Columns.Add(new DataColumn("mMake", typeof(string)));
dta.Columns.Add(new DataColumn("ModelNoA", typeof(string)));
dta.Columns.Add(new DataColumn("ModelNoM", typeof(string)));
dta.Columns.Add(new DataColumn("boatYrBuilt", typeof(string)));
dta.Columns.Add(new DataColumn("motorYrBuilt", typeof(string)));
dta.Columns.Add(new DataColumn("blength", typeof(string)));
dta.Columns.Add(new DataColumn("hullmaterial", typeof(string)));
dta.Columns.Add(new DataColumn("mhorsepower", typeof(string)));
dta.Columns.Add(new DataColumn("rdlmhorsepType", typeof(string)));
dta.Columns.Add(new DataColumn("datePurchased", typeof(string)));
dta.Columns.Add(new DataColumn("mdatePurchased", typeof(string)));
dta.Columns.Add(new DataColumn("PurchaseType", typeof(string)));
dta.Columns.Add(new DataColumn("rblmPurchasedType", typeof(string)));
dta.Columns.Add(new DataColumn("PrevOnwerName", typeof(string)));
dta.Columns.Add(new DataColumn("prevAddr", typeof(string)));
dta.Columns.Add(new DataColumn("prevCity", typeof(string)));
dta.Columns.Add(new DataColumn("PrevState", typeof(string)));
dta.Columns.Add(new DataColumn("prevzip", typeof(string)));
dta.Columns.Add(new DataColumn("mPrevOnwerName", typeof(string)));
dta.Columns.Add(new DataColumn("mprevAddr", typeof(string)));
dta.Columns.Add(new DataColumn("mprevCity", typeof(string)));
dta.Columns.Add(new DataColumn("mPrevState", typeof(string)));
dta.Columns.Add(new DataColumn("mprevzip", typeof(string)));
dta.Columns.Add(new DataColumn("buyername", typeof(string)));
dta.Columns.Add(new DataColumn("buyeraddress", typeof(string)));
dta.Columns.Add(new DataColumn("buyercity", typeof(string)));
dta.Columns.Add(new DataColumn("buyerstate", typeof(string)));
dta.Columns.Add(new DataColumn("buyerzip", typeof(string)));
dta.Columns.Add(new DataColumn("datesold", typeof(string)));
dta.Columns.Add(new DataColumn("salePrice", typeof(string)));
dta.Columns.Add(new DataColumn("Description", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyername", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyeraddress", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyercity", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyerstate", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyerzip", typeof(string)));
dta.Columns.Add(new DataColumn("mdatesold", typeof(string)));
dta.Columns.Add(new DataColumn("msalePrice", typeof(string)));
dta.Columns.Add(new DataColumn("mDescription", typeof(string)));
dta.Columns.Add(new DataColumn("boatCost", typeof(string)));
dta.Columns.Add(new DataColumn("motorCost", typeof(string)));
dta.Columns.Add(new DataColumn("rblIssues", typeof(string)));
dta.Columns.Add(new DataColumn("functionalIsses", typeof(string)));
dta.Columns.Add(new DataColumn("mrblIssues", typeof(string)));
dta.Columns.Add(new DataColumn("mfunctionalIsses", typeof(string)));
dta.Columns.Add(new DataColumn("vesseltypeUse", typeof(string)));
dta.Columns.Add(new DataColumn("vesselname", typeof(string)));
dta.Columns.Add(new DataColumn("vessellength", typeof(string)));
dta.Columns.Add(new DataColumn("vesselYrBult", typeof(string)));
dta.Columns.Add(new DataColumn("VesselHullMateria", typeof(string)));
dta.Columns.Add(new DataColumn("vesselhorsepEngine", typeof(string)));
dta.Columns.Add(new DataColumn("coastGuardNumber", typeof(string)));
dta.Columns.Add(new DataColumn("VesselYrPurchased", typeof(string)));
dta.Columns.Add(new DataColumn("PurchasedNew", typeof(string)));
dta.Columns.Add(new DataColumn("VesselPurchaseAmt", typeof(string)));
dta.Columns.Add(new DataColumn("homePort", typeof(string)));
dta.Columns.Add(new DataColumn("whereDocked", typeof(string)));
dta.Columns.Add(new DataColumn("bmequipAccessoryList", typeof(string)));
dr = dta.NewRow();
dr["RowNumber"] = 1;
dr["boatcnty"] = string.Empty;
dr["ARegNo"] = registerNumber;
dr["aMake"] = string.Empty;
dr["mMake"] = string.Empty;
dr["ModelNoA"] = string.Empty;
dr["ModelNoM"] = string.Empty;
dr["boatYrBuilt"] = string.Empty;
dr["motorYrBuilt"] = string.Empty;
dr["blength"] = string.Empty;
dr["hullmaterial"] = string.Empty;
dr["mhorsepower"] = string.Empty;
dr["rdlmhorsepType"] = string.Empty;
dr["datePurchased"] = string.Empty;
dr["mdatePurchased"] = string.Empty;
dr["PurchaseType"] = string.Empty;
dr["rblmPurchasedType"] = string.Empty;
dr["PrevOnwerName"] = string.Empty;
dr["prevAddr"] = string.Empty;
dr["prevCity"] = string.Empty;
dr["PrevState"] = string.Empty;
dr["prevzip"] = string.Empty;
dr["mPrevOnwerName"] = string.Empty;
dr["mprevAddr"] = string.Empty;
dr["mprevCity"] = string.Empty;
dr["mPrevState"] = string.Empty;
dr["mprevzip"] = string.Empty;
dr["buyername"] = string.Empty;
dr["buyeraddress"] = string.Empty;
dr["buyercity"] = string.Empty;
dr["buyerstate"] = string.Empty;
dr["buyerzip"] = string.Empty;
dr["datesold"] = string.Empty;
dr["salePrice"] = string.Empty;
dr["Description"] = string.Empty;
dr["mbuyername"] = string.Empty;
dr["mbuyeraddress"] = string.Empty;
dr["mbuyercity"] = string.Empty;
dr["mbuyerstate"] = string.Empty;
dr["mbuyerzip"] = string.Empty;
dr["mdatesold"] = string.Empty;
dr["msalePrice"] = string.Empty;
dr["mDescription"] = string.Empty;
dr["boatCost"] = string.Empty;
dr["motorCost"] = string.Empty;
dr["rblIssues"] = string.Empty;
dr["functionalIsses"] = string.Empty;
dr["mrblIssues"] = string.Empty;
dr["mfunctionalIsses"] = string.Empty;
dr["vesseltypeUse"] = string.Empty;
dr["vesselname"] = string.Empty;
dr["vessellength"] = string.Empty;
dr["vesselYrBult"] = string.Empty;
dr["VesselHullMateria"] = string.Empty;
dr["vesselhorsepEngine"] = string.Empty;
dr["coastGuardNumber"] = bregisterNumber;
dr["VesselYrPurchased"] = string.Empty;
dr["PurchasedNew"] = string.Empty;
dr["VesselPurchaseAmt"] = string.Empty;
dr["homePort"] = string.Empty;
dr["whereDocked"] = string.Empty;
dr["bmequipAccessoryList"] = string.Empty;
dta.Rows.Add(dr);
}
else
{
dta = (DataTable)ViewState["CurrentTable"];
}
ViewState["CurrentTable"] = dta;
if (dta.Rows.Count > 0)
{
Repeater2.DataSource = dta;
Repeater2.DataBind();
}
}
|
|
|
|
|
Don't use SetInitialRow2 or AddNewRow2 .
Add the missing columns in the LoadTable2 method, where I've put "…"; and add the missing row values in the PopulateRecord method, where I've put "…".
LoadTable2 will create the table if it doesn't exist, and store it in the view-state. PopulateRecord will create the rows in that table based on the other table, and bind Repeater2 to the result. The SetInitialRow2 and AddNewRow2 methods aren't needed.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You are such a genius!
This is incredible. You did all of this in a few minutes something I have been struggling with for days.
Even though I have not added all the records to PopulateRecord method, it is already beginning to populate MarineRegNo and the others to form.
Please bear with me for a few more questions.
On the LoadTable2 method, I am still getting error that registerNumber and bregisterNumber do not exist.
I will post entire LoadTable2 so you can tell me if I need to take that portion out.
private DataTable LoadTable2(bool createIfMissing)
{
const string ViewStateKey = "CurrentTable";
DataTable dt = ViewState[ViewStateKey] as DataTable;
if (dt == null && createIfMissing)
{
dt = new DataTable();
dta.Columns.Add(new DataColumn("RowNumber", typeof(string)));
dta.Columns.Add(new DataColumn("boatcnty", typeof(string)));
dta.Columns.Add(new DataColumn("aRegNo", typeof(string)));
dta.Columns.Add(new DataColumn("aMake", typeof(string)));
dta.Columns.Add(new DataColumn("mMake", typeof(string)));
dta.Columns.Add(new DataColumn("ModelNoA", typeof(string)));
dta.Columns.Add(new DataColumn("ModelNoM", typeof(string)));
dta.Columns.Add(new DataColumn("boatYrBuilt", typeof(string)));
dta.Columns.Add(new DataColumn("motorYrBuilt", typeof(string)));
dta.Columns.Add(new DataColumn("blength", typeof(string)));
dta.Columns.Add(new DataColumn("hullmaterial", typeof(string)));
dta.Columns.Add(new DataColumn("mhorsepower", typeof(string)));
dta.Columns.Add(new DataColumn("rdlmhorsepType", typeof(string)));
dta.Columns.Add(new DataColumn("datePurchased", typeof(string)));
dta.Columns.Add(new DataColumn("mdatePurchased", typeof(string)));
dta.Columns.Add(new DataColumn("PurchaseType", typeof(string)));
dta.Columns.Add(new DataColumn("rblmPurchasedType", typeof(string)));
dta.Columns.Add(new DataColumn("PrevOnwerName", typeof(string)));
dta.Columns.Add(new DataColumn("prevAddr", typeof(string)));
dta.Columns.Add(new DataColumn("prevCity", typeof(string)));
dta.Columns.Add(new DataColumn("PrevState", typeof(string)));
dta.Columns.Add(new DataColumn("prevzip", typeof(string)));
dta.Columns.Add(new DataColumn("mPrevOnwerName", typeof(string)));
dta.Columns.Add(new DataColumn("mprevAddr", typeof(string)));
dta.Columns.Add(new DataColumn("mprevCity", typeof(string)));
dta.Columns.Add(new DataColumn("mPrevState", typeof(string)));
dta.Columns.Add(new DataColumn("mprevzip", typeof(string)));
dta.Columns.Add(new DataColumn("buyername", typeof(string)));
dta.Columns.Add(new DataColumn("buyeraddress", typeof(string)));
dta.Columns.Add(new DataColumn("buyercity", typeof(string)));
dta.Columns.Add(new DataColumn("buyerstate", typeof(string)));
dta.Columns.Add(new DataColumn("buyerzip", typeof(string)));
dta.Columns.Add(new DataColumn("datesold", typeof(string)));
dta.Columns.Add(new DataColumn("salePrice", typeof(string)));
dta.Columns.Add(new DataColumn("Description", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyername", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyeraddress", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyercity", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyerstate", typeof(string)));
dta.Columns.Add(new DataColumn("mbuyerzip", typeof(string)));
dta.Columns.Add(new DataColumn("mdatesold", typeof(string)));
dta.Columns.Add(new DataColumn("msalePrice", typeof(string)));
dta.Columns.Add(new DataColumn("mDescription", typeof(string)));
dta.Columns.Add(new DataColumn("boatCost", typeof(string)));
dta.Columns.Add(new DataColumn("motorCost", typeof(string)));
dta.Columns.Add(new DataColumn("rblIssues", typeof(string)));
dta.Columns.Add(new DataColumn("functionalIsses", typeof(string)));
dta.Columns.Add(new DataColumn("mrblIssues", typeof(string)));
dta.Columns.Add(new DataColumn("mfunctionalIsses", typeof(string)));
dta.Columns.Add(new DataColumn("vesseltypeUse", typeof(string)));
dta.Columns.Add(new DataColumn("vesselname", typeof(string)));
dta.Columns.Add(new DataColumn("vessellength", typeof(string)));
dta.Columns.Add(new DataColumn("vesselYrBult", typeof(string)));
dta.Columns.Add(new DataColumn("VesselHullMateria", typeof(string)));
dta.Columns.Add(new DataColumn("vesselhorsepEngine", typeof(string)));
dta.Columns.Add(new DataColumn("coastGuardNumber", typeof(string)));
dta.Columns.Add(new DataColumn("VesselYrPurchased", typeof(string)));
dta.Columns.Add(new DataColumn("PurchasedNew", typeof(string)));
dta.Columns.Add(new DataColumn("VesselPurchaseAmt", typeof(string)));
dta.Columns.Add(new DataColumn("homePort", typeof(string)));
dta.Columns.Add(new DataColumn("whereDocked", typeof(string)));
dta.Columns.Add(new DataColumn("bmequipAccessoryList", typeof(string)));
ViewState[ViewStateKey] = dta;
}
if (dta.Rows.Count == 0)
{
DataRow dr = dta.NewRow();
dr["RowNumber"] = 1;
dr["boatcnty"] = string.Empty;
dr["ARegNo"] = registerNumber;
dr["aMake"] = string.Empty;
dr["mMake"] = string.Empty;
dr["ModelNoA"] = string.Empty;
dr["ModelNoM"] = string.Empty;
dr["boatYrBuilt"] = string.Empty;
dr["motorYrBuilt"] = string.Empty;
dr["blength"] = string.Empty;
dr["hullmaterial"] = string.Empty;
dr["mhorsepower"] = string.Empty;
dr["rdlmhorsepType"] = string.Empty;
dr["datePurchased"] = string.Empty;
dr["mdatePurchased"] = string.Empty;
dr["PurchaseType"] = string.Empty;
dr["rblmPurchasedType"] = string.Empty;
dr["PrevOnwerName"] = string.Empty;
dr["prevAddr"] = string.Empty;
dr["prevCity"] = string.Empty;
dr["PrevState"] = string.Empty;
dr["prevzip"] = string.Empty;
dr["mPrevOnwerName"] = string.Empty;
dr["mprevAddr"] = string.Empty;
dr["mprevCity"] = string.Empty;
dr["mPrevState"] = string.Empty;
dr["mprevzip"] = string.Empty;
dr["buyername"] = string.Empty;
dr["buyeraddress"] = string.Empty;
dr["buyercity"] = string.Empty;
dr["buyerstate"] = string.Empty;
dr["buyerzip"] = string.Empty;
dr["datesold"] = string.Empty;
dr["salePrice"] = string.Empty;
dr["Description"] = string.Empty;
dr["mbuyername"] = string.Empty;
dr["mbuyeraddress"] = string.Empty;
dr["mbuyercity"] = string.Empty;
dr["mbuyerstate"] = string.Empty;
dr["mbuyerzip"] = string.Empty;
dr["mdatesold"] = string.Empty;
dr["msalePrice"] = string.Empty;
dr["mDescription"] = string.Empty;
dr["boatCost"] = string.Empty;
dr["motorCost"] = string.Empty;
dr["rblIssues"] = string.Empty;
dr["functionalIsses"] = string.Empty;
dr["mrblIssues"] = string.Empty;
dr["mfunctionalIsses"] = string.Empty;
dr["vesseltypeUse"] = string.Empty;
dr["vesselname"] = string.Empty;
dr["vessellength"] = string.Empty;
dr["vesselYrBult"] = string.Empty;
dr["VesselHullMateria"] = string.Empty;
dr["vesselhorsepEngine"] = string.Empty;
dr["coastGuardNumber"] = bregisterNumber;
dr["VesselYrPurchased"] = string.Empty;
dr["PurchasedNew"] = string.Empty;
dr["VesselPurchaseAmt"] = string.Empty;
dr["homePort"] = string.Empty;
dr["whereDocked"] = string.Empty;
dr["bmequipAccessoryList"] = string.Empty;
dta.Rows.Add(dr);
}
return dta;
}
The second question I have is that I see how you assigned values to MarineRegNo and VesselRegNo.
dr["RowNumber"] = table2.Rows.Count + 1;
dr["aRegNo"] = row["MarineRegNo"];
dr["coastGuardNumber"] = row["VesselRegNo"];
Do I need to assign values from the DB to the rest like instead of this:
dr["boatcnty"] = string.Empty;
I do this:
dr["boatcnty"] = row["boatcnty"];
row["boatcnty"] is db record.
Thanks so much Richard.
|
|
|
|
|
In LoadTable2 , take out the entire if (dta.Rows.Count == 0) { ... } block. The rows are created in the PopulateRecord function, based on the rows from the other table.
Whether or not you assign values to the empty columns in the new rows depends on how you're using those columns. If you don't assign a value, the default will be null . If you try to access the length of a value that's null , you'll get a NullReferenceException . But if all you're doing is binding the data using Bind or Eval , setting the column to string.Empty won't make any difference.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Ok, got it.
Almost there but still have a couple more questions.
1, I didn't get a response to the registerNumber and bregisterNumber fields in the LoadTable2 method.
They are giving errors that they don't exist.
Finally, another method is giving me errors.
The
private void SetPreviousData2(string registerNumber, string bregisterNumber)
When called below, is giving errors that SetPreviousData2 must have a return type.
SetPreviousData2(registerNumber, bregisterNumber);
Do I need to get rid of those as well?
If I do get rid of that method, then when I click NEXT to go to page2, it is blank.
modified 21-Sep-17 16:30pm.
|
|
|
|
|
1) Look at the code I posted[^]. The LoadTable2 method does not contain any mention of registerNumber or bregisterNumber .
You added that reference back in[^] within the if (dta.Rows.Count == 0) block, which is not required, and which I told you to remove[^].
Once again, the LoadTable2 method does not create any rows. Those rows are created in the PopulateRecord method.
2) You have never posted the definition of the SetPreviousData2 method. If you can't work out how to fix it, then you're going to need to post it, along with the full details of the error.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you very sir.
I truly appreciate your patience.
SetPreviousData2 takes two arguments, RegisterNumber( to populate MarineRegNo from Repeater1 to AregNo for Repeater2) and bregisterNumber which populates VesselRegNo from Repeater1 to coastGuardNumber for Repeater2) when user clicks the NEXT button.
When SetPreviousData2(registerNumber, bregisterNumber) is called, I get an error that method must have a return type.
I suspect that those two arguments may no longer be needed given the solution you have given me.
However, even after I remove them from SetPreviousData2(...) method and I remove them from where it is called, I still get that error.
Here is where it is called as well as the method and just to avoid me coming to ask more questions, I think and please confirm that if in fact, it is no longer needed, then any place else on the page where they are referenced, I will remove them?
SetPreviousData2(registerNumber, bregisterNumber);
private void SetPreviousData2(string registerNumber, string bregisterNumber)
{
int rowIndex = 0;
if (ViewState["CurrentTable"] != null)
{
DataTable dt = (DataTable)ViewState["CurrentTable"];
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
TextBox tbaircnty = (TextBox)Repeater2.Items[rowIndex].FindControl("aircraftcnty");
TextBox tbTextBox2 = (TextBox)Repeater2.Items[rowIndex].FindControl("aRegNo");
TextBox tbaMake = (TextBox)Repeater2.Items[rowIndex].FindControl("aMake");
TextBox tbmMake = (TextBox)Repeater2.Items[rowIndex].FindControl("mMake");
TextBox tbaModelNo = (TextBox)Repeater2.Items[rowIndex].FindControl("aModelNo");
TextBox tbmModelNo = (TextBox)Repeater2.Items[rowIndex].FindControl("mModelNo");
TextBox tbboatYrBuilt = (TextBox)Repeater2.Items[rowIndex].FindControl("boatYrBuilt");
TextBox tbmotorYrBuilt = (TextBox)Repeater2.Items[rowIndex].FindControl("motorYrBuilt");
TextBox tbblength = (TextBox)Repeater2.Items[rowIndex].FindControl("blength");
TextBox tbhullmaterial = (TextBox)Repeater2.Items[rowIndex].FindControl("hullmaterial");
TextBox tbmhorsepower = (TextBox)Repeater2.Items[rowIndex].FindControl("mhorsepower");
RadioButtonList rblhoreslist = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("rdlmhorsepType");
TextBox tbdatePurchased = (TextBox)Repeater2.Items[rowIndex].FindControl("txtdatePurchased");
TextBox tbrbmdatePurchased = (TextBox)Repeater2.Items[rowIndex].FindControl("mdatePurchased");
RadioButtonList rbltypelist = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("rblPurchaseType");
RadioButtonList rblpurchasedlist = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("rblmPurchasedType");
TextBox tbPrevOnwerName = (TextBox)Repeater2.Items[rowIndex].FindControl("txtPrevOnwerName");
TextBox tbprevAddr = (TextBox)Repeater2.Items[rowIndex].FindControl("txtprevAddr");
TextBox tbprevCity = (TextBox)Repeater2.Items[rowIndex].FindControl("txtprevCity");
DropDownList tbPrevState = (DropDownList)Repeater2.Items[rowIndex].FindControl("ddlPrevState");
TextBox tbprevzip = (TextBox)Repeater2.Items[rowIndex].FindControl("txtprevzip");
TextBox tbmPrevOnwerName = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmPrevOnwerName");
TextBox tbmprevAddr = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmprevAddr");
TextBox tbmprevCity = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmprevCity");
DropDownList tbmPrevState = (DropDownList)Repeater2.Items[rowIndex].FindControl("ddlmPrevState");
TextBox tbmprevzip = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmprevzip");
TextBox tbbuyername = (TextBox)Repeater2.Items[rowIndex].FindControl("txtbuyername");
TextBox tbbuyeraddress = (TextBox)Repeater2.Items[rowIndex].FindControl("txtbuyeraddress");
TextBox tbbuyercity = (TextBox)Repeater2.Items[rowIndex].FindControl("txtbuyercity");
DropDownList tbbuyerstate = (DropDownList)Repeater2.Items[rowIndex].FindControl("lblbuyerstate");
TextBox tbbuyerzip = (TextBox)Repeater2.Items[rowIndex].FindControl("txtbuyerzip");
TextBox txtdatesold = (TextBox)Repeater2.Items[rowIndex].FindControl("txtdatesold");
TextBox tbsalePrice = (TextBox)Repeater2.Items[rowIndex].FindControl("txtsalePrice");
TextBox tbDescription = (TextBox)Repeater2.Items[rowIndex].FindControl("txtDescription");
TextBox tbmbuyername = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmbuyername");
TextBox tbmbuyeraddress = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmbuyeraddress");
TextBox tbmbuyercity = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmbuyercity");
DropDownList tbmbuyerstate = (DropDownList)Repeater2.Items[rowIndex].FindControl("lblmbuyerstate");
TextBox tbmbuyerzip = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmbuyerzip");
TextBox tbmdatesold = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmdatesold");
TextBox tbmsalePrice = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmsalePrice");
TextBox tbmDescription = (TextBox)Repeater2.Items[rowIndex].FindControl("txtmDescription");
TextBox tbboatCost = (TextBox)Repeater2.Items[rowIndex].FindControl("boatCost");
TextBox tbmotorCost = (TextBox)Repeater2.Items[rowIndex].FindControl("motorCost");
RadioButtonList rbllist1 = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("rblIssues");
TextBox tbfunctionalIsses = (TextBox)Repeater2.Items[rowIndex].FindControl("functionalIsses");
RadioButtonList rbllist2 = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("mrblIssues");
TextBox tbmfunctionalIsses = (TextBox)Repeater2.Items[rowIndex].FindControl("mfunctionalIsses");
TextBox tbvesseltypeUse = (TextBox)Repeater2.Items[rowIndex].FindControl("txtvesseltypeUse");
TextBox tbvesselname = (TextBox)Repeater2.Items[rowIndex].FindControl("txtvesselname");
TextBox tbvessellength = (TextBox)Repeater2.Items[rowIndex].FindControl("txtvessellength");
TextBox tbvesselYrBult = (TextBox)Repeater2.Items[rowIndex].FindControl("txtvesselYrBult");
TextBox tbVesselHullMateria = (TextBox)Repeater2.Items[rowIndex].FindControl("txtVesselHullMateria");
TextBox tbvesselhorsepEngine = (TextBox)Repeater2.Items[rowIndex].FindControl("vesselhorsepEngine");
TextBox tbcoastGuardNumber = (TextBox)Repeater2.Items[rowIndex].FindControl("coastGuardNumber");
TextBox txtVesselYrPurchased = (TextBox)Repeater2.Items[rowIndex].FindControl("txtVesselYrPurchased");
RadioButtonList PurchasedNew = (RadioButtonList)Repeater2.Items[rowIndex].FindControl("rblVPurchasedNew");
TextBox tbVesselPurchaseAmt = (TextBox)Repeater2.Items[rowIndex].FindControl("VesselPurchaseAmt");
TextBox tbtxthomePort = (TextBox)Repeater2.Items[rowIndex].FindControl("txthomePort");
TextBox tbtxtwhereDocked = (TextBox)Repeater2.Items[rowIndex].FindControl("txtwhereDocked");
TextBox tbbmequipAccessoryList = (TextBox)Repeater2.Items[rowIndex].FindControl("bmequipAccessoryList");
tbaircnty.Text = dt.Rows[i]["boatcnty"].ToString();
tbTextBox2.Text = dt.Rows[i]["aRegNo"].ToString();
tbaMake.Text = dt.Rows[i]["aMake"].ToString();
tbmMake.Text = dt.Rows[i]["mMake"].ToString();
tbaModelNo.Text = dt.Rows[i]["ModelNoA"].ToString();
tbmModelNo.Text = dt.Rows[i]["ModelNoM"].ToString();
tbboatYrBuilt.Text = dt.Rows[i]["boatYrBuilt"].ToString();
tbmotorYrBuilt.Text = dt.Rows[i]["motorYrBuilt"].ToString();
tbblength.Text = dt.Rows[i]["blength"].ToString();
tbhullmaterial.Text = dt.Rows[i]["hullmaterial"].ToString();
tbmhorsepower.Text = dt.Rows[i]["mhorsepower"].ToString();
if (!string.IsNullOrEmpty(dt.Rows[i]["rdlmhorsepType"].ToString()))
{
rblhoreslist.Items.FindByText(dt.Rows[i]["rdlmhorsepType"].ToString()).Selected = true;
}
tbdatePurchased.Text = dt.Rows[i]["datePurchased"].ToString();
tbrbmdatePurchased.Text = dt.Rows[i]["mdatePurchased"].ToString();
if (!string.IsNullOrEmpty(dt.Rows[i]["PurchaseType"].ToString()))
{
rbltypelist.Items.FindByText(dt.Rows[i]["PurchaseType"].ToString()).Selected = true;
}
if (!string.IsNullOrEmpty(dt.Rows[i]["rblmPurchasedType"].ToString()))
{
rblpurchasedlist.Items.FindByText(dt.Rows[i]["rblmPurchasedType"].ToString()).Selected = true;
}
tbPrevOnwerName.Text = dt.Rows[i]["PrevOnwerName"].ToString();
tbprevAddr.Text = dt.Rows[i]["prevAddr"].ToString();
tbprevCity.Text = dt.Rows[i]["prevCity"].ToString();
tbPrevState.Text = dt.Rows[i]["PrevState"].ToString();
tbprevzip.Text = dt.Rows[i]["prevzip"].ToString();
tbmPrevOnwerName.Text = dt.Rows[i]["mPrevOnwerName"].ToString();
tbmprevAddr.Text = dt.Rows[i]["mprevAddr"].ToString();
tbmprevCity.Text = dt.Rows[i]["mprevCity"].ToString();
tbmprevzip.Text = dt.Rows[i]["mprevzip"].ToString();
tbbuyername.Text = dt.Rows[i]["buyername"].ToString();
tbbuyeraddress.Text = dt.Rows[i]["buyeraddress"].ToString();
tbbuyercity.Text = dt.Rows[i]["buyercity"].ToString();
tbbuyerstate.Text = dt.Rows[i]["buyerstate"].ToString();
tbbuyerzip.Text = dt.Rows[i]["buyerzip"].ToString();
txtdatesold.Text = dt.Rows[i]["datesold"].ToString();
tbsalePrice.Text = dt.Rows[i]["salePrice"].ToString();
tbDescription.Text = dt.Rows[i]["Description"].ToString();
tbmbuyername.Text = dt.Rows[i]["mbuyername"].ToString();
tbmbuyeraddress.Text = dt.Rows[i]["mbuyeraddress"].ToString();
tbmbuyerstate.Text = dt.Rows[i]["mbuyerstate"].ToString();
tbmbuyerzip.Text = dt.Rows[i]["mbuyerzip"].ToString();
tbmdatesold.Text = dt.Rows[i]["mdatesold"].ToString();
tbmsalePrice.Text = dt.Rows[i]["msalePrice"].ToString();
tbmDescription.Text = dt.Rows[i]["mDescription"].ToString();
tbboatCost.Text = dt.Rows[i]["boatCost"].ToString();
tbmotorCost.Text = dt.Rows[i]["motorCost"].ToString();
if (!string.IsNullOrEmpty(dt.Rows[i]["rblIssues"].ToString()))
{
rbllist1.Items.FindByText(dt.Rows[i]["rblIssues"].ToString()).Selected = true;
}
tbfunctionalIsses.Text = dt.Rows[i]["functionalIsses"].ToString();
if (!string.IsNullOrEmpty(dt.Rows[i]["mrblIssues"].ToString()))
{
rbllist2.Items.FindByText(dt.Rows[i]["mrblIssues"].ToString()).Selected = true;
}
tbmfunctionalIsses.Text = dt.Rows[i]["mfunctionalIsses"].ToString();
tbvesseltypeUse.Text = dt.Rows[i]["vesseltypeUse"].ToString();
tbvesselname.Text = dt.Rows[i]["vesselname"].ToString();
tbvessellength.Text = dt.Rows[i]["vessellength"].ToString();
tbvesselYrBult.Text = dt.Rows[i]["vesselYrBult"].ToString();
tbVesselHullMateria.Text = dt.Rows[i]["VesselHullMateria"].ToString();
tbvesselhorsepEngine.Text = dt.Rows[i]["vesselhorsepEngine"].ToString();
tbcoastGuardNumber.Text = dt.Rows[i]["coastGuardNumber"].ToString();
txtVesselYrPurchased.Text = dt.Rows[i]["VesselYrPurchased"].ToString();
if (!string.IsNullOrEmpty(dt.Rows[i]["PurchasedNew"].ToString()))
{
PurchasedNew.Items.FindByText(dt.Rows[i]["PurchasedNew"].ToString()).Selected = true;
}
tbVesselPurchaseAmt.Text = dt.Rows[i]["VesselPurchaseAmt"].ToString();
tbtxthomePort.Text = dt.Rows[i]["homePort"].ToString();
tbtxtwhereDocked.Text = dt.Rows[i]["whereDocked"].ToString();
tbbmequipAccessoryList.Text = dt.Rows[i]["bmequipAccessoryList"].ToString();
if (dt.Rows.Count - 1 == i)
{
tbTextBox2.Text = registerNumber;
tbcoastGuardNumber.Text = bregisterNumber;
}
rowIndex++;
}
}
}
}
Thank you very much.
God was on my side yesterday as management cancelled the scheduled demo due to other commitments.
|
|
|
|
|
There's nothing in that code which would cause that compiler error. Which line does the error refer to?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The error is on this line:
SetPreviousData2(registerNumber, bregisterNumber);
I don't know if it is because is it not being called by another method.
When I tested yesterday even before I added all the codes, I was able to go to the next page (Repeater2) and the two values for AregNo from MarineRegNo and coastGuardNumber from VesselRegNo were there.
Then that error started.
By the way, I did remove the if=== block you told me to remove yesterday.
It turned out that I was getting those errors from SetInitialRow2() because I forgot to remove that method and that method was calling SetPreviousData() methos.
|
|
|
|
|
samflex wrote: I don't know if it is because is it not being called by another method.
What do you mean by that?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
What I meant was that before, I was calling it inside AddNewRow2 method.
This error, I think started after I removed the AddNewRow2 method.
If I comment that line:
SetPreviousData2(registerNumber, bregisterNumber), then when click the NEXT button, the page is blank.
It may be that it is no longer needed but something is breaking the page.
|
|
|
|
|
Ok, I think the problem is here, not necessarily your problem but I may have missed something here because right now, when I click the NEXT page, it loads the form correctly except that the value of MarineRegNo and VesselRegNo in Repeater1 that were to populate AregNo and coastGuardNumber respectively, are not populating them.
Could it be in this method?
YEAR - FOUND IT!!
I had AregNo and coastGuardNumber twice, one empty and the other not.
NOW, when I enter values for Repeater1, they appear in Repeater2, YEAAA.
The real which I am about to try now is when I submit the data and try to populate the form with the account number, will the data I submitted load?
You are so gifted, I gush with jealousy.
private void PopulateRecord(DataTable table1)
{
DataTable table2 = LoadTable2(true);
table2.Rows.Clear();
foreach (DataRow row in table1.Rows)
{
DataRow dr = table2.NewRow();
dr["RowNumber"] = table2.Rows.Count + 1;
dr["aRegNo"] = row["MarineRegNo"];
dr["coastGuardNumber"] = row["VesselRegNo"];
dr["boatcnty"] = string.Empty;
dr["ARegNo"] = string.Empty;
dr["aMake"] = string.Empty;
dr["mMake"] = string.Empty;
dr["ModelNoA"] = string.Empty;
dr["ModelNoM"] = string.Empty;
dr["boatYrBuilt"] = string.Empty;
dr["motorYrBuilt"] = string.Empty;
dr["blength"] = string.Empty;
dr["hullmaterial"] = string.Empty;
dr["mhorsepower"] = string.Empty;
dr["rdlmhorsepType"] = string.Empty;
dr["datePurchased"] = string.Empty;
dr["mdatePurchased"] = string.Empty;
dr["PurchaseType"] = string.Empty;
dr["rblmPurchasedType"] = string.Empty;
dr["PrevOnwerName"] = string.Empty;
dr["prevAddr"] = string.Empty;
dr["prevCity"] = string.Empty;
dr["PrevState"] = string.Empty;
dr["prevzip"] = string.Empty;
dr["mPrevOnwerName"] = string.Empty;
dr["mprevAddr"] = string.Empty;
dr["mprevCity"] = string.Empty;
dr["mPrevState"] = string.Empty;
dr["mprevzip"] = string.Empty;
dr["buyername"] = string.Empty;
dr["buyeraddress"] = string.Empty;
dr["buyercity"] = string.Empty;
dr["buyerstate"] = string.Empty;
dr["buyerzip"] = string.Empty;
dr["datesold"] = string.Empty;
dr["salePrice"] = string.Empty;
dr["Description"] = string.Empty;
dr["mbuyername"] = string.Empty;
dr["mbuyeraddress"] = string.Empty;
dr["mbuyercity"] = string.Empty;
dr["mbuyerstate"] = string.Empty;
dr["mbuyerzip"] = string.Empty;
dr["mdatesold"] = string.Empty;
dr["msalePrice"] = string.Empty;
dr["mDescription"] = string.Empty;
dr["boatCost"] = string.Empty;
dr["motorCost"] = string.Empty;
dr["rblIssues"] = string.Empty;
dr["functionalIsses"] = string.Empty;
dr["mrblIssues"] = string.Empty;
dr["mfunctionalIsses"] = string.Empty;
dr["vesseltypeUse"] = string.Empty;
dr["vesselname"] = string.Empty;
dr["vessellength"] = string.Empty;
dr["vesselYrBult"] = string.Empty;
dr["VesselHullMateria"] = string.Empty;
dr["vesselhorsepEngine"] = string.Empty;
dr["coastGuardNumber"] = string.Empty;
dr["VesselYrPurchased"] = string.Empty;
dr["PurchasedNew"] = string.Empty;
dr["VesselPurchaseAmt"] = string.Empty;
dr["homePort"] = string.Empty;
dr["whereDocked"] = string.Empty;
dr["bmequipAccessoryList"] = string.Empty;
table2.Rows.Add(dr);
}
Repeater2.DataSource = table2;
Repeater2.DataBind();
foreach (RepeaterItem item in Repeater2.Items)
{
((Button)item.FindControl("BtnAdd2")).Visible = table2.Rows.Count > 1;
((Button)item.FindControl("btnDelete2")).Visible = table2.Rows.Count > 1;
}
}
|
|
|
|
|
I am sorry for the bad news sir but I am getting nullReference exception on the following markup:
<%foreach (System.Data.DataRow row in dtAirInfoTable.Rows)
{%>
<tr>
<td>
<%=row.ItemArray[1].ToString()%>
</td>
<td align="center">
<%=row.ItemArray[2].ToString()%>
</td>
</tr>
<tr>
<td>
<%=row.ItemArray[3].ToString()%>
</td>
<td align="center">
<%=row.ItemArray[4].ToString()%>
</td>
</tr>
<% } %>
I used to have this line:
ViewState["TempData"] = dtCurrentTable;
on the OnClickNext method but it has changed and that line is no longer there.
Then on another method, I would reference it thus:
public DataTable dtAirInfoTable;
lblTotalPrev.Text = hfvalue.Value;
if (ViewState["TempData"] != null)
{
dtAirInfoTable = (DataTable)ViewState["TempData"];
}
This would allow me to display the values from these:
TextBox tbboatregNum = (TextBox)item.FindControl("txtboatregNum");
TextBox tbPayerret = (TextBox)item.FindControl("txtPayerret");
TextBox tbCGvesselNum = (TextBox)item.FindControl("cgaurdNumber");
TextBox tbCGtaxpayerret = (TextBox)item.FindControl("cguardreturnedval");
DataRow row = dt.Rows[rowIndex];
row["MarineRegNo"] = tbboatregNum.Text;
row["TaxPyrRetdVal"] = tbPayerret.Text;
row["VesselRegNo"] = tbCGvesselNum.Text;
row["VesselTaxPyrRetdVal"] = tbCGtaxpayerret.Text;
and display their total in this line:
lblTotal.Text = hfvalue.Value;
|
|
|
|
|
If you haven't set the default values for the columns, then the value will be null . Calling .ToString() on a null value will throw a NullReferenceException . Either set the default values for the columns, or use Convert.ToString(row.ItemArray[1]) .
As far as I can see, "TempData" was only ever set to the first table; in which case, you can replace it with:
lblTotalPrev.Text = hfvalue.Value;
dtAirInfoTable = LoadTable1(false);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Everything looks great sir.
I am able to enter data on Repeater1 and those that need to appear in Repeater2 are appearing correctly.
The issue I have had in the past is that I would go through this process to insert records into the database successfully but when I try inserting another record, it is blind.
I am confident it is all fixed up now but I want to be sure when I go all the way to insert into the database but I am not able to do so because of an unrelated bug I am trying to resolve.
Once that is resolve, I will post a feedback.
Thanks so much Richard.
You have come through for me so many times. This is huge.
|
|
|
|
|