Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
S

samflex

@samflex
About
Posts
350
Topics
120
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Display text and background color based on Gridview cell value
    S samflex

    The following code displays master/detail form and when the master is expanded, displays details associated with the master record. It works as expected. Here is that code:

    'HTML
    function expanCollapse(input) {
    var displayIcon = "img" + input;
    if ($("#" + displayIcon).attr("src") == "images/plus.png")
    {
    $("#" + displayIcon).closest("tr")
    .after("<tr><td></td><td colspan = '100%'>" + $("#" + input)
    .html() + "</td></tr>");
    $("#" + displayIcon).attr("src", "images/minus.png");
    } else
    {
    $("#" + displayIcon).closest("tr").next().remove();
    $("#" + displayIcon).attr("src", "images/plus.png");
    }
    }

    		[');">
    			" src="images/plus.png" />](JavaScript:expanCollapse\('div<%# Eval\()
    

    " style="display: none;">

    'VB

    Protected Sub Page\_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    
        If Not Me.IsPostBack Then
    
        End If
        Dim sql As String = "SELECT e.EmployeeID, e.empID, e.employeeName,e.empTitle, e.email "
    
    ASP.NET javascript html database

  • 'copydHtml' is not declared. It may be inaccessible due to its protection level.
    S samflex

    Greetings, I am totally confused by this error on the Subject line. On my html page, I have this:

    ...
    ...
    ...

    Then near the bottom of the page, I have this:

    $(function () {
        $("\[id\*=btnSend\]").click(function () {
            $("\[id\*=copydHtml\]").val($("#Grid").html());
        });
    });
    

    Finally, on the VB code, I have this:

    Protected Sub SendData(sender As Object, e As EventArgs)
    Dim sr As New StringReader(Request.Form('copydHtml.UniqueID))
    ...
    ...
    ...
    End Sub

    I just keep getting the error: 'copydHtml' is not declared. It may be inaccessible due to its protection level. I am very confused by this error because I can't seem to figure why the error keeps coming up. Any ideas anybody?

    ASP.NET html css help question

  • Display records based on selected date range in months within same year?
    S samflex

    I wasn't going to delete the thread once someone had responded to it. Here is what ultimately worked for me.

    SELECT e.Name, e.email, e.emptitle, d.dateSubmitted,
    CASE WHEN YEAR(d.dateSubmitted) < YEAR(getdate()) THEN 1 ELSE 0 END as previousYear,
    CASE WHEN d.dateSubmitted >= '20240301' AND d.dateSubmitted < '20240501' THEN 1 ELSE 0 END as thisYear
    FROM Employees e
    INNER JOIN dateDetails d on e.employeeID = d.employeeID
    WHERE e.employeeID = someID

    Database question help

  • Display records based on selected date range in months within same year?
    S samflex

    You could have easily told me if my code was right or wrong. Anyway, I have resolved it. I was actually coming here to delete the thread.

    Database question help

  • Display records based on selected date range in months within same year?
    S samflex

    Greetings, How do I ensure that the following code only queries records that are submitted between March and May 2024? If a record has been submitted between the above date range, display 1. Otherwise, display 0. Currently, we have a code that does this but for entire year. In the code below, I left the code that performs this check with alias of thisYear. I left this line of code but commented it out just to show what we have that works except this time, we just want this check to be between March and May 2024. The code: CASE WHEN d.dateCreated BETWEEN DATEFROMPARTS(2024, 3, 1) AND DATEFROMPARTS(2024, 5 + 1, 1) THEN 1 ELSE 0 END as thisYear appears to work sometimes but does not work other times. No errors but wrong results. That code above, temporarily replaces this line of code below as described above.

    --CASE WHEN YEAR(d.dateCreated) = YEAR(getdate()) THEN 1 ELSE 0 END as thisYear

    Here is the entire code:

     SELECT e.Name, e.email, e.emptitle, d.dateCreated,
         CASE WHEN YEAR(d.dateSubmitted) < YEAR(getdate()) THEN 1 ELSE 0 END as previousYear,
         --CASE WHEN YEAR(d.dateSubmitted) = YEAR(getdate()) THEN 1 ELSE 0 END as thisYear
     CASE WHEN d.dateSubmitted BETWEEN DATEFROMPARTS(2024, 3, 1) AND DATEFROMPARTS(2024, 5 + 1, 1) THEN 1 ELSE 0 END as thisYear
    FROM Employees e 
    INNER JOIN dateDetails d on e.employeeID = d.employeeID
    WHERE e.employeeID = someID
    

    I have also tried this:

    CASE WHEN d.dateSubmitted >= DATEFROMPARTS(2024, 3, 1) AND d.dateSubmitted < DATEFROMPARTS(2024,5 + 1, 1)

    Same inconsistent result. I guess my question is why does this work perfectly:

    CASE WHEN YEAR(d.dateSubmitted) = YEAR(getdate()) THEN 1 ELSE 0 END as thisYear

    but the date range does not work well? Thanks in advance for your help.

    Database question help

  • Is is possible to import an excel file with hyperlinks?
    S samflex

    Hi, I suppose that when you say target address of a hyperlink, you meant the location you are taking when you click on a hyperlink? Here is what we are trying to accomplish. We have directory on our server where several documents are stored. Then the excel file contains hyperlinks to those documents. For instance, one of the columns, called Director for example, the Director is hyperlinked Director. On the excel file, it is clearly hyperlinked and when clicked, takes you to the Files directory and Director file. There are over 600 of these records on excel. What we are trying to do is import the contents of the excel file to the database then use our .net app to display these records on our site so users can visit the site search for any title info, find it, cick the hyperlink to take him/her to the file on the server. So, after importing the file to the database, all you see now is the text Director. The hyperlink is stripped away.

    ASP.NET database csharp asp-net sql-server sysadmin

  • Is is possible to import an excel file with hyperlinks?
    S samflex

    LOL, The only way I have done import from excel to SQL Server is to use the SQL Server import utility. It always works. If you have imported files before to sql server, then nothing to guess there. The only issue this time around is that when I imported the file, the hyperlinks on the values for one of the columns was removed. Normally, this is not an issue for anyone who has encountered this type of problem. All I have asked for is whether anyone has had similar issue and if yes, how did they resolved it. Nothing really complicated about my question. If I Have a code and I am having problem making it work, I post the code and ask for help which I have done many times here.

    ASP.NET database csharp asp-net sql-server sysadmin

  • Is is possible to import an excel file with hyperlinks?
    S samflex

    There is no code sir. I am just asking about importing excel with hyperlinks to sql server or asp.net applications.

    ASP.NET database csharp asp-net sql-server sysadmin

  • Is is possible to import an excel file with hyperlinks?
    S samflex

    I have an excel file with five (5) columns. All the records in the second column are hyperlinked. When I tried importing the file to SQL Server, the hyperlinks are gone. I have spent almost 4 days googling to see if there is a way to do import this excel file with hyperlink either to a SQL Server DB or asp.net application but to no avail. Wondering if any of you experts has an idea how to do solve this problem? Many thanks in advance.

    ASP.NET database csharp asp-net sql-server sysadmin

  • (SOLVED) StringBuilder error
    S samflex

    WOW, knowledge is power. Thank you very much sir and great to hear from you again :) With your advise, I was able to successfully use ClosedXML and it is working great. I still have this solution you provided here as a back up. Thank you again.

    ASP.NET help question

  • (SOLVED) StringBuilder error
    S samflex

    Right, you are correct. I have actually removed them from there but added them some place else like:

    dtExportExcel.RenderControl(htmlWrite)
    Response.Write(stringWriter.ToString())

    ASP.NET help question

  • (SOLVED) StringBuilder error
    S samflex

    Thank you. I saw a similar code but written in C# that has exact same code and users say it worked for them. Thank you for your help. I will try this and hopefully, it works.

    ASP.NET help question

  • (SOLVED) StringBuilder error
    S samflex

    Ok, thank you very much for your response. So, this would have been the correct way?

    sb.Append("")

    ASP.NET help question

  • (SOLVED) StringBuilder error
    S samflex

    Hi all, We are currently having problem with data exported to excel. When we review the exported file, some show values with exponential format. To try to work around that, I have the code below with stringbuilder to fix the exponential format issue.

    Public Sub GetExcel(ByVal dt As DataTable)
        Dim fileName As String = "file" & DateTime.Now.ToString("MMddyyyy") & ".xls"
        Response.AddHeader("content-disposition", "attachment;filename=" & fileName)
        Response.ContentType = "application/vnd.ms-excel"
        Dim stringWriter As StringWriter = New StringWriter()
        Dim htmlWrite As HtmlTextWriter = New HtmlTextWriter(stringWriter)
        Dim dtExportExcel As DataGrid = New DataGrid()
        dtExportExcel.DataSource = dt
        dtExportExcel.DataBind()
        dtExportExcel.RenderControl(htmlWrite)
        Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()
        sb.Append("  table { mso-number-format:'0'; }  ")
        sb.Append(stringWriter & "")
        Response.Write(sb.ToString())
        Response.\[End\]()
    End Sub
    

    When I run the code, I get an error on this line:

    sb.Append(stringWriter & "")

    The error says, Operator '&' is s not defined for types 'StringWriter' and 'String' Any ideas what this means? Thanks in advance

    ASP.NET help question

  • How to return to previous section without losing data
    S samflex

    I have a unique situation where all asp.net markup code are all one page divided by sections. In one particular section called

    sect_MPE

    , all markups are stored in this section. Users would enter data into textbox and DropDownList controls nd click the Preview button. If user has a has a need to go back to the previous section to make changes, the user is allowed to do so by click the Go Back button. Below is the method I have created for going back to the previous section.

        Private Sub returnwithvalues()
            
            sect\_MPE.Show()
            
            'Create and assign session variables
            
            'Save txtDateReceived into a session variable for later use. Do this for rest of form fields
            Session("dtReceived") = txtDateReceived.Text
    
            If Session("dtReceived") IsNot Nothing Then
                Dim dteReceived As String = Session("dtReceived").ToString()
                txtDateReceived.Text = dteReceived
            End If
            
            Session("Iaddress") = instAddress.Text
            If Session("Iaddress") IsNot Nothing Then
                Dim ia As String = Session("Iaddress").ToString()
                instAddress.Text = ia
            End If
            
        End Sub
        
        
        Protected Sub goBack\_Click(ByVal sender As Object, ByVal e As EventArgs) Handles goBack.Click
      returnwithvalues()
        End Sub
    

    When a user clicks the Go Back button, s/he is taken to the correct section, Sect_MPE section but values on the form are lost. Could please help with what's wrong with the code I posted above. In the sample code I posted above for instance, initially, the value of the form fields are stored in session. Then when user clicks to go go back, the values in session is stored back into the form field so the data persists. I might be approaching it incorrectly. Thanks in advance for your assistance.

    ASP.NET csharp html asp-net json help

  • How do I ensure Repeater rows remain visible when adding a new blank row?
    S samflex

    Can someone please help? I have attached two screenshots to help explain the issue I am having. The first screenshot shows what happens when I value is selected from DropDownList2. It automatically displays the row with 5 columns with values. https://www.kenig-dev.tech/wp-content/uploads/2023/03/1.png[^] The second screenshot shows when the user changes the value of DropDownList2 from 1 to 2. Rather than retain the first row with values and add a second black row, the first row was reset and replaced with 2 blank rows. https://www.kenig-dev.tech/wp-content/uploads/2023/03/2.png[^] How can we retain the first row with its values while adding a second blank row that allows user to enter values into that second row?

    ASP.NET question database

  • How do I ensure Repeater rows remain visible when adding a new blank row?
    S samflex

    I have 2 dropdowns, DroDownList1 and DropDownList2. To insert records into the database, I select a value from DropDownList1 and based on specified condition, a value is automatically inserted into DropDownList2. Then when I select a value, say 1, from DropDownList2, one row is automatically created in Repeater control. If I select 2, two rows are automatically created. Finally, if I select 3 again from DropDownList2, three rows are automatically created in Repeater control. Three rows is the maximum number of rows that can be created because 3 values (1,2,3) are the maximum that can be populated into DropDownList2. Then we insert the records into the database. This entire operation works great. Then to retrieve the records we just inserted based on the description above, I use the following method:

        Protected Sub btnSearch(ByVal sender As Object, ByVal e As EventArgs)
    
            Dim address As String = Request.Form(txtSearch.UniqueID)
    
            'get the results and fill in the form 
            Dim sqlStatement As String = "Select ad.returnonly, ad.Assets,ad.NoOfItemsToReplace,ap.MailAddress,o.PrimaryFirst, o.Phone, o.AltPhone,o.Email,o.PrimaryLast, o.ownerID, ap.applicant, FORMAT(ap.DateReceived, 'd','us') as DateReceived,ad.InstallAddress,ad.InstallCity, ad.InstallState, ad.InstallZip from Applications ap "
            sqlStatement += "inner Join Addresses ad on ap.WaterAccountNo = ad.WaterAcctNo inner join Owner o on ap.OwnerCode = o.OwnerID Where ad.Installation = 1 and ad.InstallAddress Like '%" & address.Replace("'", "''").Trim() & "%'"
    
            Dim sqlCmd As SqlCommand = New SqlCommand(sqlStatement, myConnection)
            Dim reader As SqlDataReader = sqlCmd.ExecuteReader()
    
            If reader.HasRows Then
                While reader.Read()
                    DropDownList1.Text = reader("Assets").ToString()
                    DropDownList1\_SelectedIndexChanged(Nothing, Nothing)
                    DropDownList2.Text = reader("NoOfItemsToReplace").ToString()
    
                End While
    
            Else
    
            End If
            reader.Close()
            sqlCmd.Dispose()
          End Sub
    

    The above method populates DropdownList1 values and selects the inserted value by default. For instance, if 2 is selected from the list and inserted into the database, during select statements, 2 will be selected as the default value for DropDownList1. Same is the case with DropDownList2 but more importantly, the below method

    ASP.NET question database

  • How to dynamically select RadioButtonList value for Yes or No from the database
    S samflex

    We have a RadioButonList with a Yes or No choice, however, we would like the choices to be dynamically populated from the database. In other words, we have a column name called IsVetoVote. It is Bit datatype with 1 for Yes or 0 for No value. If a user queries the database for a particular proposal to see if this proposal has been voted on, if the answer is yes (or 1), we would like the RadioButtonList Yes box to the checked. If no (or 0), then the RadioButtonList No box to be checked. My code below is not giving me either Yes or No value. When I run the query portion of the code in SSMS, I get the correct result of either 1 or 0 but the RadioButtonList is not getting checked. Any ideas what could be wrong with the code?

    myConnection.Open()
    Dim strSQL As String
    
    strSQL = "Select IsVetoVote from Ballots where choices Like '%' + @vetono + '%'"
    Dim command As SqlCommand = New SqlCommand(strSQL, myConnection)
    With command.Parameters
        .Add(New SqlParameter("@vetono", SqlDbType.NVarChar).Value = location.Replace("'", "''").Trim())
    End With
    
    'Fill a dataset with data from the Ballots table.
    Dim ds As New DataSet
    Dim da As New SqlDataAdapter(strSQL, myConnection)
    da.Fill(ds, "tblreturns")
    
    If (ds.Tables(0).Rows.Count > 0) Then
           Else
        Dim returns As String = (ds.Tables("tblreturns").Rows(0).Item("IsVetoVote"))
    
        For Each r As ListItem In VetoVote.Items
            If r.Value = returns Then
                r.Selected = True
            End If
        Next
    
    End If
    
    ASP.NET database sql-server tutorial question

  • Copying from billing address to mailing address if they are the same not working correctly
    S samflex

    Thank you for your response sir but it did not work. In other words, the value of WI did not get copied to the mailState DropDownList. I tried hardcoding the State value since that will always be the same like this:

    var thestate = 'WI';
    if (thestate !== "") {
    $('#mailState').val(thestate);
    }

    It appears to change something on the mailState dropdownlist but did not display that WI value in the dropdown. Instead, it showed blank value as the selected value on the mailState dropdownlist box.

    JavaScript question

  • Copying from billing address to mailing address if they are the same not working correctly
    S samflex

    I have a form that asks users to provide their billing and shipping addresses. If the billing address is same as the mailing address, click a checkbox to copy the billing address information to mailing address boxes. So far, address, city and zip are getting copied from billing to mailing addresses but the State address is not getting copy. The billing State has a hardcoded value of WI for Wisconsin. That NEVER changes, hence it is hardcoded. The mailing address for State has a DropDownList of states, I am pretty sure that has to do with why the billing address for State is not getting cover over to mailing address for State. Can you guys please see what I am doing wrong? Here is what I am working with.

            $('#SameAsMailing').click(function () {
                 if ($('input\[name="SameAsMailing"\]').is(':checked')) { 
                 $('#mailStreetAddress').val($('#instAddress').val());
                 $('#mailCity').val($('#instAddressCity').val()); 
                 var thestate = $('#instAddressState option:selected').val();
                 if (thestate != "") {
                             $('#mailState option\[value="' + thestate + '"\]').prop('selected', true);
                      } 
                 $('#mailZip').val($('#instAddressZip').val());
                 }
               else
                {
                //Clear on uncheck
                $('#mailStreetAddress').val("");
                $('#mailCity').val("");
                $('#mailState option:eq(0)').prop('selected', true);
                $('#mailZip').val("");
               }
             }); 
           
    
        
          Install Address:
    		    
    	City:
                   
        City:
    	
    	State:
    	
    	Zip:
    
    JavaScript question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups