Click here to Skip to main content
15,881,248 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: How can I properly use the Trace.Write() method inside of my for loop to print month and future values? Pin
Richard Deeming22-Sep-17 2:11
mveRichard Deeming22-Sep-17 2:11 
QuestionSystem.ServiceModel.FaultException`1 occurred Pin
jkirkerx21-Sep-17 12:05
professionaljkirkerx21-Sep-17 12:05 
AnswerRe: System.ServiceModel.FaultException`1 occurred Pin
jkirkerx22-Sep-17 6:29
professionaljkirkerx22-Sep-17 6:29 
AnswerUPS Rate SOAP WSDL Errors in VS2017 Service Reference, An exception has been raised as a result of client data. Pin
jkirkerx22-Sep-17 11:07
professionaljkirkerx22-Sep-17 11:07 
QuestionRepeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex20-Sep-17 4:38
samflex20-Sep-17 4:38 
AnswerRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming20-Sep-17 10:15
mveRichard Deeming20-Sep-17 10:15 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex21-Sep-17 3:50
samflex21-Sep-17 3:50 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming21-Sep-17 5:12
mveRichard Deeming21-Sep-17 5:12 
I'm not sure I'm following exactly what you're doing, but I'd be inclined to start by tidying up the code:
C#
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.

GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex21-Sep-17 6:33
samflex21-Sep-17 6:33 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming21-Sep-17 6:39
mveRichard Deeming21-Sep-17 6:39 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex21-Sep-17 7:26
samflex21-Sep-17 7:26 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming21-Sep-17 7:32
mveRichard Deeming21-Sep-17 7:32 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex21-Sep-17 8:32
samflex21-Sep-17 8:32 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming21-Sep-17 8:55
mveRichard Deeming21-Sep-17 8:55 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex21-Sep-17 9:39
samflex21-Sep-17 9:39 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming21-Sep-17 9:47
mveRichard Deeming21-Sep-17 9:47 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex21-Sep-17 10:03
samflex21-Sep-17 10:03 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming22-Sep-17 1:52
mveRichard Deeming22-Sep-17 1:52 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex22-Sep-17 3:29
samflex22-Sep-17 3:29 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming22-Sep-17 3:35
mveRichard Deeming22-Sep-17 3:35 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex22-Sep-17 3:49
samflex22-Sep-17 3:49 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming22-Sep-17 4:39
mveRichard Deeming22-Sep-17 4:39 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex22-Sep-17 4:56
samflex22-Sep-17 4:56 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex22-Sep-17 5:09
samflex22-Sep-17 5:09 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex22-Sep-17 5:35
samflex22-Sep-17 5:35 

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.