Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
headware #1
can't get data to show with bound columns
I'm trying to create a DataGrid filled with values from a DataSet and
I want the user to be able to show and hide whichever columns they
choose. I have a dropdown list box filled with the column names so the
user can select a column name and hit a button to hide or show it.
I originally tried to use an unbound DataGrid with autogenerated
columns, however the DataGrid.Columns collection is empty when all the
columns are autogenerated (which seems unnecessarily unfriendly to me,
but that's beside the point). As a result the table displayed the
correct data but I had no way to access the columns in order to hide
them.
So I tried to set up explicitly bound columns. I changed the
"autogenerate columns" property to false and specified the same amount
of columns in the DataGrid as the DataSet was returning. Now, I have
the opposite functionality. I can get the columns to show and hide but
the data isn't showing up in the grid. It has no rows. What's going on
here? Is there any better way to do this? It's driving me nuts.
Thanks
headware Guest
-
Dynamically data-bound columns versus asp:ButtonColumn
I'm working on a small application where I'd like to have a select column in a DataGrid displaying a result set returned from a stored proc. ... -
bound columns of a datagrid
i have a datagrid with few bound columns.i want to make the first column clickable.can i make a bound column clickable and write a handler for... -
Binding to bound columns
I've been trying to figure out how to use the design time column creation of columns. I turn off AutoGenerateColumns and create the bound columns... -
DG-Edit-Loosing data; bound columns - pushbuttons; dataReader
Dear Readers, I am using C# (vb examples will work for me too - i am vb progrmr). I created a dg (datagrid) with bound columns (hesistant to... -
iterate through bound columns
Hello, I have several pages with datagrids, and I was thinking of writing a common excel function. I want to iterate through the columns of... -
Alvin Bruney #2
Re: can't get data to show with bound columns
go back to the autogenerated column. here is the code to hide it
you need to do this in the itemdatabound event handler
foreach(string toHide in ListBox1)
{
if(toHide != " ")
e.Item.Cells[int.Parse(toHide)].Visible = false;
}
toHide would be an index of the selected item instead of the string because
Cells only takes an int.
happy camping
"headware" <headware@aol.com> wrote in message
news:e3f4b0ae.0307081851.166cac5@posting.google.co m...> I'm trying to create a DataGrid filled with values from a DataSet and
> I want the user to be able to show and hide whichever columns they
> choose. I have a dropdown list box filled with the column names so the
> user can select a column name and hit a button to hide or show it.
> I originally tried to use an unbound DataGrid with autogenerated
> columns, however the DataGrid.Columns collection is empty when all the
> columns are autogenerated (which seems unnecessarily unfriendly to me,
> but that's beside the point). As a result the table displayed the
> correct data but I had no way to access the columns in order to hide
> them.
> So I tried to set up explicitly bound columns. I changed the
> "autogenerate columns" property to false and specified the same amount
> of columns in the DataGrid as the DataSet was returning. Now, I have
> the opposite functionality. I can get the columns to show and hide but
> the data isn't showing up in the grid. It has no rows. What's going on
> here? Is there any better way to do this? It's driving me nuts.
>
> Thanks
Alvin Bruney Guest
-
headware x #3
Re: can't get data to show with bound columns
Well, the DataGrid.Items property doesn't have a Cells property so I'm
not sure what you mean. Do you mean the DataGrid.Columns collection? If
so, it still doesn't contain anything by the time execution gets to the
ItemDateBound event, so it's pretty much the same situation as before.
By the way, I'm doing this in C#, not VB if that matters.
Thanks
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
headware x Guest
-
Alvin Bruney #4
Re: can't get data to show with bound columns
you need to do this in the itemdatabound event handler.
For every row that gets bound in a grid, the itemdatabound event fires which
implies it must have something to bind to. If you look at my posted code, I
said e.Items.Cells. e comes from the itemdatabound event handler - it's part
of the event args.
"headware x" <headware@aol.com> wrote in message
news:uurPQYeRDHA.704@tk2msftngp13.phx.gbl...> Well, the DataGrid.Items property doesn't have a Cells property so I'm
> not sure what you mean. Do you mean the DataGrid.Columns collection? If
> so, it still doesn't contain anything by the time execution gets to the
> ItemDateBound event, so it's pretty much the same situation as before.
> By the way, I'm doing this in C#, not VB if that matters.
>
> Thanks
>
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
Alvin Bruney Guest
-
headware #5
Re: can't get data to show with bound columns
Gotcha, thanks for the help!
"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in message news:<efvD57nRDHA.2188@TK2MSFTNGP10.phx.gbl>...> you need to do this in the itemdatabound event handler.
> For every row that gets bound in a grid, the itemdatabound event fires which
> implies it must have something to bind to. If you look at my posted code, I
> said e.Items.Cells. e comes from the itemdatabound event handler - it's part
> of the event args.
>
> "headware x" <headware@aol.com> wrote in message
> news:uurPQYeRDHA.704@tk2msftngp13.phx.gbl...> > Well, the DataGrid.Items property doesn't have a Cells property so I'm
> > not sure what you mean. Do you mean the DataGrid.Columns collection? If
> > so, it still doesn't contain anything by the time execution gets to the
> > ItemDateBound event, so it's pretty much the same situation as before.
> > By the way, I'm doing this in C#, not VB if that matters.
> >
> > Thanks
> >
> >
> > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> > Don't just participate in USENET...get rewarded for it!headware Guest



Reply With Quote

