473,383 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

unbind a datagrid, datalist, repeater, drop down etc

How do you unbind one of these web controls.

I have a drop down list that based on another drop down list selection will
be databouns

private void BindDD2(int id)
{
DD2.DataSource = MyClass.GetList2(id);
DD2.DataBind();
}

Now, if i want to reset this drop down back to its pre bound state, how
would i do this.

I've tried:

1)
DD2.DataSource = null; //didn't work
2)
foreach(ListItem l in DD2.Items)
DD2.Items.Remoce(l); //also don't work
3)
DataSet ds = new DataSet();
DD2.DataSource = ds;
DD2.DataBind(); //this throws an error.
So, any ideas

TIA
Nov 19 '05 #1
5 6473
Hi!

Try DD2.Items.Clear()

HTH,
Lars-Erik

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:OM****************@TK2MSFTNGP10.phx.gbl...
How do you unbind one of these web controls.

I have a drop down list that based on another drop down list selection
will be databouns

private void BindDD2(int id)
{
DD2.DataSource = MyClass.GetList2(id);
DD2.DataBind();
}

Now, if i want to reset this drop down back to its pre bound state, how
would i do this.

I've tried:

1)
DD2.DataSource = null; //didn't work
2)
foreach(ListItem l in DD2.Items)
DD2.Items.Remoce(l); //also don't work
3)
DataSet ds = new DataSet();
DD2.DataSource = ds;
DD2.DataBind(); //this throws an error.
So, any ideas

TIA

Nov 19 '05 #2
DD2.Items.Clear();

Eliyahu

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:OM****************@TK2MSFTNGP10.phx.gbl...
How do you unbind one of these web controls.

I have a drop down list that based on another drop down list selection will be databouns

private void BindDD2(int id)
{
DD2.DataSource = MyClass.GetList2(id);
DD2.DataBind();
}

Now, if i want to reset this drop down back to its pre bound state, how
would i do this.

I've tried:

1)
DD2.DataSource = null; //didn't work
2)
foreach(ListItem l in DD2.Items)
DD2.Items.Remoce(l); //also don't work
3)
DataSet ds = new DataSet();
DD2.DataSource = ds;
DD2.DataBind(); //this throws an error.
So, any ideas

TIA

Nov 19 '05 #3
knew it was something simple

Thanks :)

"Lars-Erik Aabech" <la******@newsgroup.nospam> wrote in message
news:Oy**************@TK2MSFTNGP09.phx.gbl...
Hi!

Try DD2.Items.Clear()

HTH,
Lars-Erik

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:OM****************@TK2MSFTNGP10.phx.gbl...
How do you unbind one of these web controls.

I have a drop down list that based on another drop down list selection
will be databouns

private void BindDD2(int id)
{
DD2.DataSource = MyClass.GetList2(id);
DD2.DataBind();
}

Now, if i want to reset this drop down back to its pre bound state, how
would i do this.

I've tried:

1)
DD2.DataSource = null; //didn't work
2)
foreach(ListItem l in DD2.Items)
DD2.Items.Remoce(l); //also don't work
3)
DataSet ds = new DataSet();
DD2.DataSource = ds;
DD2.DataBind(); //this throws an error.
So, any ideas

TIA


Nov 19 '05 #4
so DD2.Items.Clear() works perfectly on a dropdown
but hows about a DataGrid?

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:OM****************@TK2MSFTNGP10.phx.gbl...
How do you unbind one of these web controls.

I have a drop down list that based on another drop down list selection
will be databouns

private void BindDD2(int id)
{
DD2.DataSource = MyClass.GetList2(id);
DD2.DataBind();
}

Now, if i want to reset this drop down back to its pre bound state, how
would i do this.

I've tried:

1)
DD2.DataSource = null; //didn't work
2)
foreach(ListItem l in DD2.Items)
DD2.Items.Remoce(l); //also don't work
3)
DataSet ds = new DataSet();
DD2.DataSource = ds;
DD2.DataBind(); //this throws an error.
So, any ideas

TIA

Nov 19 '05 #5
Depends if you want to keep the column headers. If not, you could just
create an empty data source and bind. :)

DataTable dt = new DataTable();
// Create columns here..
DataGrid1.DataSource = dt;
DataGrid1.DataBind();

Or you could set DataGrid1.EnableViewState = false, and repost the page..

You could even do SELECT * FROM myTable WHERE myId = 0 and fill the data
source, then you'd have the columns, but no data..

The possibilities are many ;)

Lars-Erik

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
so DD2.Items.Clear() works perfectly on a dropdown
but hows about a DataGrid?

"Grant Merwitz" <gr***@workshare.com> wrote in message
news:OM****************@TK2MSFTNGP10.phx.gbl...
How do you unbind one of these web controls.

I have a drop down list that based on another drop down list selection
will be databouns

private void BindDD2(int id)
{
DD2.DataSource = MyClass.GetList2(id);
DD2.DataBind();
}

Now, if i want to reset this drop down back to its pre bound state, how
would i do this.

I've tried:

1)
DD2.DataSource = null; //didn't work
2)
foreach(ListItem l in DD2.Items)
DD2.Items.Remoce(l); //also don't work
3)
DataSet ds = new DataSet();
DD2.DataSource = ds;
DD2.DataBind(); //this throws an error.
So, any ideas

TIA


Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jeremy Ames | last post by:
I am trying to use a datagrid to pull information from a database. I prefer to use latebinding to this. Well, I finally got my information to populate the datagrid, but the information came out in...
7
by: Scott Schluer | last post by:
Hi All, I have a functioning datagrid on "Page 1" that displays order information for a single order (this is for an e-commerce site). It's actually a combination of a couple datagrids to...
0
by: Paul | last post by:
I want to be able to nest a repeater in a datagrid or datalist. I'm not unduly bothered about a master/child relationship as such as there'll at this stage only ever be one record on the page, but...
3
by: moondaddy | last post by:
I have a page listing all the addresses for a customer and I want 2 addresses per row. Each address is in a template column so I can add special formatting and buttons. My problem is that each...
2
by: Simon Harris | last post by:
Hi All, I have an app which requires a list of coutries to be displayed, so far I have a datagrid which contains displays the countries Ok, along with flag images, these are also links to my...
1
by: Mike | last post by:
Hi! Been stuck on this one for a bit. Would really appreciate any help on this one. To start. I have a sql database table with the following data and design (ex) ...
2
by: Stimp | last post by:
I would like to produce something like: http://redwoodestates.co.uk/forrent.aspx It's either a datalist/repeater/datagrid, but it is broken up into sections ("1 bedroom", "2 bedroom", etc...)...
3
by: Fao, Sean | last post by:
I have a DataGrid that I'm adding CheckBox controls to at runtime (in the code behind) and I'm not sure if I'm doing it correctly. First of all, I noticed that the MyDataGrid.Columns.Add() method...
2
by: champ.supernova | last post by:
I have a repeater, which contains in its <HEADERTEMPLATEa drop-down list (set to autopostback). If the page is a postback, I want to modify the SQL of the repeater's datasource, DEPENDING ON the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.