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
  1. Home
  2. Web Development
  3. SharePoint
  4. Correct display of SPList and Refreshing? [solved]

Correct display of SPList and Refreshing? [solved]

Scheduled Pinned Locked Moved SharePoint
databasequestionsharepointtutorial
2 Posts 1 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NuKeR_2k
    wrote on last edited by
    #1

    Hello everybody, I'm currently working on a project where I have to develope an Sharepoint web part. My webpart does fetch external data from an MS SQL database and add each entry in a SPList, I created programmatically before. Furthermore I have an form where you can filter each list field by check/uncheck some checkboxes. For example if I uncheck the Checkbox "RAM" I want to hide the column "RAM" of my list. This works well. But if I check this checkbox again, the column will not be shown. In the List which was created in the sharepoint website content, everything works fine but not so in the list I render in my webpart. I searched a long time for a solution but I can't find what I've made wrong. So my question is: how I can correctly render and refresh a SPList? My source code follows below. Thanking you in anticipation for reading and helping. PS: sorry for my terrible english ;) Best regards nki ----------------------------------------------------------------- After button click, the sql statement will be assembled. Furthermore the the list will be rendered.

    private void SubmitClick(object sender, EventArgs e)
    {
      string sqlSelects = "select ";
    
      if (m\_cbShowPC.Checked)      sqlSelects += "pc.LI\_PCNAME,";
      if (m\_cbShowOS.Checked)      sqlSelects += "os.LI\_TYPE,";
      if (m\_cbShowSP.Checked)      sqlSelects += "os.LI\_SERVICEPACK,";
      if (m\_cbShowUUID.Checked)    sqlSelects += "pc.LI\_UUID,";
      if (m\_cbShowName.Checked)    sqlSelects += "acc.LI\_USERFULLNAME,";
      if (m\_cbShowCPU.Checked)     sqlSelects += "cpu.LI\_NAME,";
      if (m\_cbShowCores.Checked)   sqlSelects += "cpu.LI\_NUMCORES,";
      if (m\_cbShowMHz.Checked)     sqlSelects += "cpu.LI\_MHZ,";
      if (m\_cbShowRAM.Checked)     sqlSelects += "ram.LI\_SIZE,";
      if (m\_cbShowIP.Checked)      sqlSelects += "net.LI\_IPADDRESS,";
      if (m\_cbShowSubnet.Checked)  sqlSelects += "net.LI\_SUBNETMASK";
               
      m\_SqlQuery = sqlSelects + " from LI\_ACCOUNT acc " +
                                    "INNER JOIN LI\_PCINFO pc  ON acc.LA\_ID = pc.LA\_ID " +
                                    "INNER JOIN LI\_OS     os  ON acc.LA\_ID = os.LA\_ID " +
                                    "INNER JOIN LI\_CPU    cpu ON acc.LA\_ID = cpu.LA\_ID " +
                                    "INNER JOIN LI\_RAM    ram ON acc.LA\_ID = ram.LA\_ID " +
                                    "INNER JOIN LI\_NET    net ON acc.LA\_ID = net.LA\_ID " +
                                "where " +
    
    N 1 Reply Last reply
    0
    • N NuKeR_2k

      Hello everybody, I'm currently working on a project where I have to develope an Sharepoint web part. My webpart does fetch external data from an MS SQL database and add each entry in a SPList, I created programmatically before. Furthermore I have an form where you can filter each list field by check/uncheck some checkboxes. For example if I uncheck the Checkbox "RAM" I want to hide the column "RAM" of my list. This works well. But if I check this checkbox again, the column will not be shown. In the List which was created in the sharepoint website content, everything works fine but not so in the list I render in my webpart. I searched a long time for a solution but I can't find what I've made wrong. So my question is: how I can correctly render and refresh a SPList? My source code follows below. Thanking you in anticipation for reading and helping. PS: sorry for my terrible english ;) Best regards nki ----------------------------------------------------------------- After button click, the sql statement will be assembled. Furthermore the the list will be rendered.

      private void SubmitClick(object sender, EventArgs e)
      {
        string sqlSelects = "select ";
      
        if (m\_cbShowPC.Checked)      sqlSelects += "pc.LI\_PCNAME,";
        if (m\_cbShowOS.Checked)      sqlSelects += "os.LI\_TYPE,";
        if (m\_cbShowSP.Checked)      sqlSelects += "os.LI\_SERVICEPACK,";
        if (m\_cbShowUUID.Checked)    sqlSelects += "pc.LI\_UUID,";
        if (m\_cbShowName.Checked)    sqlSelects += "acc.LI\_USERFULLNAME,";
        if (m\_cbShowCPU.Checked)     sqlSelects += "cpu.LI\_NAME,";
        if (m\_cbShowCores.Checked)   sqlSelects += "cpu.LI\_NUMCORES,";
        if (m\_cbShowMHz.Checked)     sqlSelects += "cpu.LI\_MHZ,";
        if (m\_cbShowRAM.Checked)     sqlSelects += "ram.LI\_SIZE,";
        if (m\_cbShowIP.Checked)      sqlSelects += "net.LI\_IPADDRESS,";
        if (m\_cbShowSubnet.Checked)  sqlSelects += "net.LI\_SUBNETMASK";
                 
        m\_SqlQuery = sqlSelects + " from LI\_ACCOUNT acc " +
                                      "INNER JOIN LI\_PCINFO pc  ON acc.LA\_ID = pc.LA\_ID " +
                                      "INNER JOIN LI\_OS     os  ON acc.LA\_ID = os.LA\_ID " +
                                      "INNER JOIN LI\_CPU    cpu ON acc.LA\_ID = cpu.LA\_ID " +
                                      "INNER JOIN LI\_RAM    ram ON acc.LA\_ID = ram.LA\_ID " +
                                      "INNER JOIN LI\_NET    net ON acc.LA\_ID = net.LA\_ID " +
                                  "where " +
      
      N Offline
      N Offline
      NuKeR_2k
      wrote on last edited by
      #2

      Hello again, I've solved this problem. I had to delete the view of the SPList before: I just add the following code at the end of AddView():

        try
        {
          SPView view = m\_InventList.Views\["Overview"\];
          if (view != null)
            m\_InventList.Views.Delete(view.ID);
        }
        catch (System.Exception)
        {
        }
      
        m\_InventList.Views.Add("Overview", strColl, @"", 200, true, true, SPViewCollection.SPViewType.Html, false);
        m\_InventList.Update();
      

      Best regards nki

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

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