This is a migrated thread and some comments may be shown as answers.

Add new item in Panel and save it for future

3 Answers 24 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
dotnetrockerzzz
Top achievements
Rank 2
dotnetrockerzzz asked on 12 Oct 2010, 11:48 AM
I have following code :

protected void Button1_Click(object sender, EventArgs e)
    {
        RadPanelItem newItem = new RadPanelItem(RadTextBox1.Text);
        RadPanelBar1.Items.Add(newItem);
         
    }
 Currently the scenario is ---
User Clicks on button the item is added . When user refreshes the page the value is gone . 

Wanted Scenario ----
User Clicks on button the item is added . When user refreshes the page the value is still there

I do not want any databases involved plz if possible . Thank You . Reply me fast plz 

3 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 12 Oct 2010, 02:36 PM
Hello Vaibhav,

You can use an XML file, instead of a database, to save the PanelBar structure. The following demo shows how to databind the PanelBar to an xml file.

http://demos.telerik.com/aspnet-ajax/panelbar/examples/populatingwithdata/xmldefinition/defaultcs.aspx

To save the PanelBar items, back to the xml file. You can the PanelBar.GetXml() method and then use a TextWriter to write the content to your xml file.

I hope that helps.
0
dotnetrockerzzz
Top achievements
Rank 2
answered on 13 Oct 2010, 11:23 AM
@Cori
"" use a TextWriter to write the content to your xml file."" Can u please explain me how ? Remember I want the value from a Textbox .  Thanks for the reply XML did not strike to me . Thanks .
Vaibhav
0
Cori
Top achievements
Rank 2
answered on 13 Oct 2010, 01:51 PM
You use the same code you posted in your first post, where you add it to the PanelBar. You then just create the TextWriter and pass it the content from GetXml. Something like this:

RadPanelBarItem newItem = new RadPanelBarItem(RadTextBox1.Text);
RadPanelBar1.Items.Add(newItem);
  
StreamWriter sw = new StreamWriter("PanelBarItems.xml");
sw.Write(RadPanelBar1.GetXml());
sw.Flush();
sw.Close();

That should do the trick.

I hope that helps.
Tags
PanelBar
Asked by
dotnetrockerzzz
Top achievements
Rank 2
Answers by
Cori
Top achievements
Rank 2
dotnetrockerzzz
Top achievements
Rank 2
Share this question
or