Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Perecli Manole #1
adding rows
In my DataGrid I need to have two rows of data for every bound record. I
have successfully achieved this by adding datagrid items and cells through
code in the "DataGrid.ItemDataBound" event. The problem is that on post back
my added rows do not stay. Aparently one needs to recreate them each page
request. I have read several articles that suggest building up your grid
layout in the "DataGrid.ItemCreated" event which gets called every request.
So I put my row adding code there but then I realized that this event gets
called before the framework adds its default row in the grid which creates a
problem. I need my row to be added after the framework adds the default row
so that it can be placed below it. I can not place a row with an index after
a row that has not been created by the framework. So for now it seems like
the only solution is to bind the grid on every request which is a waste. Is
there another solution.
Perry
Perecli Manole Guest
-
ASP.NET 2 GridView: Adding rows
Hi How can I programatically add rows and then edit cells in C# for the ASP.NET 2 GridView? I want to create a table basically where I can... -
Adding more rows to one column/cell only?
I have a basic table of three columns and 10 rows. I want to add two more rows to the last column only (it's an ordering form, and the last... -
Adding extra rows to a DataGrid?
Hi everyone, I'm using a DataGrid to show records from a SQL query. The problem is, I'd really like to have two "extra" rows for every one... -
Adding rows to DataGrid across multiple PostBacks
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest... -
Adding rows to a Datagrid
Jason, Thanks for the reply. Yes... it would be possible... but I also don't want to commit deletes/changes to the child records until they are... -
Raghavendra T V #2
Re: adding rows
Hi Perecli,
I guess if you could put your code which adds rows to datagrid in a function
and
call them the Datagrid events and you need to take care of postback by
checking for Page.IsPostBack
Thanks
Raghavendra
"Perecli Manole" <Perry@argowin.com> wrote in message
news:Ooyo88%23iEHA.2140@TK2MSFTNGP15.phx.gbl...back> In my DataGrid I need to have two rows of data for every bound record. I
> have successfully achieved this by adding datagrid items and cells through
> code in the "DataGrid.ItemDataBound" event. The problem is that on postrequest.> my added rows do not stay. Aparently one needs to recreate them each page
> request. I have read several articles that suggest building up your grid
> layout in the "DataGrid.ItemCreated" event which gets called everya> So I put my row adding code there but then I realized that this event gets
> called before the framework adds its default row in the grid which createsrow> problem. I need my row to be added after the framework adds the defaultafter> so that it can be placed below it. I can not place a row with an indexIs> a row that has not been created by the framework. So for now it seems like
> the only solution is to bind the grid on every request which is a waste.> there another solution.
>
> Perry
>
>
Raghavendra T V Guest
-
Perecli Manole #3
Re: adding rows
The code that adds rows can not be in a generic function because the rows
need to be added in a special iterative function such as
"DataGrid.ItemDataBound" or "DataGrid.ItemCreated". These functions are
special in that they are called by the framework once per record and the
framework passes in the current DataItem and RowItem being proccessed. I can
not duplicate this behavior with a standard function call.
Perry
"Raghavendra T V" <raagzvb@hotmail.com> wrote in message
news:e5T4BfBjEHA.1712@TK2MSFTNGP09.phx.gbl...> Hi Perecli,
>
> I guess if you could put your code which adds rows to datagrid in a
> function
> and
> call them the Datagrid events and you need to take care of postback by
> checking for Page.IsPostBack
>
> Thanks
> Raghavendra
>
> "Perecli Manole" <Perry@argowin.com> wrote in message
> news:Ooyo88%23iEHA.2140@TK2MSFTNGP15.phx.gbl...> back>> In my DataGrid I need to have two rows of data for every bound record. I
>> have successfully achieved this by adding datagrid items and cells
>> through
>> code in the "DataGrid.ItemDataBound" event. The problem is that on post> request.>> my added rows do not stay. Aparently one needs to recreate them each page
>> request. I have read several articles that suggest building up your grid
>> layout in the "DataGrid.ItemCreated" event which gets called every> a>> So I put my row adding code there but then I realized that this event
>> gets
>> called before the framework adds its default row in the grid which
>> creates> row>> problem. I need my row to be added after the framework adds the default> after>> so that it can be placed below it. I can not place a row with an index> Is>> a row that has not been created by the framework. So for now it seems
>> like
>> the only solution is to bind the grid on every request which is a waste.>>> there another solution.
>>
>> Perry
>>
>>
>
Perecli Manole Guest
-
Alvin Bruney [MVP] #4
Re: adding rows
what you need to do is add the rows to the dataset instead. whenever you
bind, the extra rows are always there and you don't need to go thru the
hocus pocus of postback and viewstate hell
--
Regards,
Alvin Bruney
[ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
"Perecli Manole" <Perry@argowin.com> wrote in message
news:Ooyo88%23iEHA.2140@TK2MSFTNGP15.phx.gbl...> In my DataGrid I need to have two rows of data for every bound record. I
> have successfully achieved this by adding datagrid items and cells through
> code in the "DataGrid.ItemDataBound" event. The problem is that on post
> back my added rows do not stay. Aparently one needs to recreate them each
> page request. I have read several articles that suggest building up your
> grid layout in the "DataGrid.ItemCreated" event which gets called every
> request. So I put my row adding code there but then I realized that this
> event gets called before the framework adds its default row in the grid
> which creates a problem. I need my row to be added after the framework
> adds the default row so that it can be placed below it. I can not place a
> row with an index after a row that has not been created by the framework.
> So for now it seems like the only solution is to bind the grid on every
> request which is a waste. Is there another solution.
>
> Perry
>
Alvin Bruney [MVP] Guest
-
Perecli Manole #5
Re: adding rows
You missunderstand my requirement. The reason I need to add a row dynamicaly
to the grid is because my row table strucuture needs to be changed. For
every row in the database I need two rows in the grid. First row for each
record should have one column structure and shows half the data while the
second row has a different column structure and shows the other half of the
data. In edit mode I need to go back to a "signle row/single column" because
I show an entry form in it. I have achieved this by altering the grid's
structure in the DataBind event however I have the problem described in my
previous post.
Perry
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:u2y3qpTjEHA.3876@TK2MSFTNGP15.phx.gbl...> what you need to do is add the rows to the dataset instead. whenever you
> bind, the extra rows are always there and you don't need to go thru the
> hocus pocus of postback and viewstate hell
>
> --
> Regards,
> Alvin Bruney
> [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
> Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
> "Perecli Manole" <Perry@argowin.com> wrote in message
> news:Ooyo88%23iEHA.2140@TK2MSFTNGP15.phx.gbl...>>> In my DataGrid I need to have two rows of data for every bound record. I
>> have successfully achieved this by adding datagrid items and cells
>> through code in the "DataGrid.ItemDataBound" event. The problem is that
>> on post back my added rows do not stay. Aparently one needs to recreate
>> them each page request. I have read several articles that suggest
>> building up your grid layout in the "DataGrid.ItemCreated" event which
>> gets called every request. So I put my row adding code there but then I
>> realized that this event gets called before the framework adds its
>> default row in the grid which creates a problem. I need my row to be
>> added after the framework adds the default row so that it can be placed
>> below it. I can not place a row with an index after a row that has not
>> been created by the framework. So for now it seems like the only solution
>> is to bind the grid on every request which is a waste. Is there another
>> solution.
>>
>> Perry
>>
>
Perecli Manole Guest
-
Alvin Bruney [MVP] #6
Re: adding rows
you will need to bind on every request, or you can try putting the bind code
early in the pipeline so that it can participate in viewstate. you will have
to look at the pipeline events to find a suitable one (prerender comes to
mind but i'm not sure that it is early enough to participate in viewstate)
--
Regards,
Alvin Bruney
[ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
"Perecli Manole" <Perry@argowin.com> wrote in message
news:OF7oY9ujEHA.592@TK2MSFTNGP11.phx.gbl...> You missunderstand my requirement. The reason I need to add a row
> dynamicaly to the grid is because my row table strucuture needs to be
> changed. For every row in the database I need two rows in the grid. First
> row for each record should have one column structure and shows half the
> data while the second row has a different column structure and shows the
> other half of the data. In edit mode I need to go back to a "signle
> row/single column" because I show an entry form in it. I have achieved
> this by altering the grid's structure in the DataBind event however I have
> the problem described in my previous post.
>
> Perry
>
>
> "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
> news:u2y3qpTjEHA.3876@TK2MSFTNGP15.phx.gbl...>>> what you need to do is add the rows to the dataset instead. whenever you
>> bind, the extra rows are always there and you don't need to go thru the
>> hocus pocus of postback and viewstate hell
>>
>> --
>> Regards,
>> Alvin Bruney
>> [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
>> Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
>> "Perecli Manole" <Perry@argowin.com> wrote in message
>> news:Ooyo88%23iEHA.2140@TK2MSFTNGP15.phx.gbl...>>>>> In my DataGrid I need to have two rows of data for every bound record. I
>>> have successfully achieved this by adding datagrid items and cells
>>> through code in the "DataGrid.ItemDataBound" event. The problem is that
>>> on post back my added rows do not stay. Aparently one needs to recreate
>>> them each page request. I have read several articles that suggest
>>> building up your grid layout in the "DataGrid.ItemCreated" event which
>>> gets called every request. So I put my row adding code there but then I
>>> realized that this event gets called before the framework adds its
>>> default row in the grid which creates a problem. I need my row to be
>>> added after the framework adds the default row so that it can be placed
>>> below it. I can not place a row with an index after a row that has not
>>> been created by the framework. So for now it seems like the only
>>> solution is to bind the grid on every request which is a waste. Is there
>>> another solution.
>>>
>>> Perry
>>>
>>
>
Alvin Bruney [MVP] Guest
-
Perecli Manole #7
Re: adding rows
Even on load was not early enough to participate in viewstate. I have tried
this in the Initialize event and it works except the viewstate gets
confused. Apparently the columns and row modifications I am making to the
grid are offsetting the viewstate matching so I get same good results and
some garbled results. The framework dows not seem to save the viewstate of
the dynamic alterations to the grid but only of the datagrid as it thinks
was built. The trick is not to use the built in viewstate and manage it
yourself. What I ended up doing is saving the DataSet result in the view
state too that way even though I am binding on every postback, the net
result is still only one DB hit. Only one problem remains. The fields that
are shown in edit mode do not hold their values when a post is made that
shows a validation error. I need to somehow get the Forms values and
populate my controls with them as in the old ASP days. Any suggestions?
Thanks
Perry
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:%23CMdPB3jEHA.3632@TK2MSFTNGP09.phx.gbl...> you will need to bind on every request, or you can try putting the bind
> code early in the pipeline so that it can participate in viewstate. you
> will have to look at the pipeline events to find a suitable one (prerender
> comes to mind but i'm not sure that it is early enough to participate in
> viewstate)
>
> --
> Regards,
> Alvin Bruney
> [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
> Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
> "Perecli Manole" <Perry@argowin.com> wrote in message
> news:OF7oY9ujEHA.592@TK2MSFTNGP11.phx.gbl...>>> You missunderstand my requirement. The reason I need to add a row
>> dynamicaly to the grid is because my row table strucuture needs to be
>> changed. For every row in the database I need two rows in the grid. First
>> row for each record should have one column structure and shows half the
>> data while the second row has a different column structure and shows the
>> other half of the data. In edit mode I need to go back to a "signle
>> row/single column" because I show an entry form in it. I have achieved
>> this by altering the grid's structure in the DataBind event however I
>> have the problem described in my previous post.
>>
>> Perry
>>
>>
>> "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
>> news:u2y3qpTjEHA.3876@TK2MSFTNGP15.phx.gbl...>>>>> what you need to do is add the rows to the dataset instead. whenever you
>>> bind, the extra rows are always there and you don't need to go thru the
>>> hocus pocus of postback and viewstate hell
>>>
>>> --
>>> Regards,
>>> Alvin Bruney
>>> [ASP.NET MVP [url]http://mvp.support.microsoft.com/default.aspx][/url]
>>> Got tidbits? Get it here... [url]http://tinyurl.com/27cok[/url]
>>> "Perecli Manole" <Perry@argowin.com> wrote in message
>>> news:Ooyo88%23iEHA.2140@TK2MSFTNGP15.phx.gbl...
>>>> In my DataGrid I need to have two rows of data for every bound record.
>>>> I have successfully achieved this by adding datagrid items and cells
>>>> through code in the "DataGrid.ItemDataBound" event. The problem is that
>>>> on post back my added rows do not stay. Aparently one needs to recreate
>>>> them each page request. I have read several articles that suggest
>>>> building up your grid layout in the "DataGrid.ItemCreated" event which
>>>> gets called every request. So I put my row adding code there but then I
>>>> realized that this event gets called before the framework adds its
>>>> default row in the grid which creates a problem. I need my row to be
>>>> added after the framework adds the default row so that it can be placed
>>>> below it. I can not place a row with an index after a row that has not
>>>> been created by the framework. So for now it seems like the only
>>>> solution is to bind the grid on every request which is a waste. Is
>>>> there another solution.
>>>>
>>>> Perry
>>>>
>>>
>>>
>>
>
Perecli Manole Guest



Reply With Quote

