Home All Groups Group Topic Archive Search About
Author
23 Feb 2005 7:38 PM
Vishal
Hello,

   I have a datagrid, which creates the columns
dynamically based on the columns in the dataset. Now I
need to add an additional row for each exisiting row AND
hide that row, by default. This row will contain my
usercontrol, which I will add also dynamically.
Unfortunaly I am not able to do so. I tried two options:

1.) I added the rows to the dataset and bound the dataset
to the datagrid.

- The problem however is, that I am not able to set the
span of that row somehow. I set it, but it doesnt take it.

- The second problem is that I am not able to hide it. I
dont see any attributes property for the DataRow. Here is
the code:

...begin loop through the rows
  Dim NestedGridRow As DataRow = ds.Tables(0).NewRow
  Dim NestedCell As New TableCell
  NestedCell.ColumnSpan = 3 'ds.Tables(0).Columns.Count
  ds.Tables(0).Rows.InsertAt(NestedGridRow, nRowPosition)
  nRowPosition = nRowPosition + 2
...end loop through the rows

2.) I tried to add the columns direclty to the datagrid,
via the following code:

...begin loop through the rows
  Dim dgItem As DataGridItem
  Dim dgCell As TableCell
  dgItem = New DataGridItem(0, 0, ListItemType.Item)
  dgCell = New TableCell
  dgCell.ColumnSpan = AADataGridStores.Columns.Count
  dgItem.Cells.Add(dgCell)
  dgCell.Text = "Testing something..."
  Dim t As Table = AADataGridStores.Controls(0)
  t.Rows.AddAt(nRowPosition, dgItem)
  nRowPosition = nRowPosition + 2
...end loop through the rows

But this doesnt work too and it gives the error:
Specified argument was out of the range of valid values.
Parameter name: index

Now how I am supposed to add a new row which I can hide?
Manually, I would place the row into a placeholder and set
the placeholder property either to true/false. But I am
not getting how to do that in my situation. Can somebody
please help me with this one?

Thanks

Author
23 Feb 2005 8:34 PM
Elton Wang
Hi Vishal,

I think basically your code of second option is OK. But,
there two things you should take into consideration:

1. Where to run the code? It should be after datagrid data
binding. It may be in PreRender.

2. Loop scope. Depending on different setting, you may
have or not Pager, Header, Footer. If you have any of
them, you should count them and add rows beyond them.

HTH

Elton Wang
elton_w***@hotmail.com




Show quoteHide quote
>-----Original Message-----
>Hello,
>
>   I have a datagrid, which creates the columns
>dynamically based on the columns in the dataset. Now I
>need to add an additional row for each exisiting row AND
>hide that row, by default. This row will contain my
>usercontrol, which I will add also dynamically.
>Unfortunaly I am not able to do so. I tried two options:
>
>1.) I added the rows to the dataset and bound the dataset
>to the datagrid.
>
>- The problem however is, that I am not able to set the
>span of that row somehow. I set it, but it doesnt take
it.
>
>- The second problem is that I am not able to hide it. I
>dont see any attributes property for the DataRow. Here is
>the code:
>
>...begin loop through the rows
>  Dim NestedGridRow As DataRow = ds.Tables(0).NewRow
>  Dim NestedCell As New TableCell
>  NestedCell.ColumnSpan = 3 'ds.Tables(0).Columns.Count
>  ds.Tables(0).Rows.InsertAt(NestedGridRow, nRowPosition)
>  nRowPosition = nRowPosition + 2
>...end loop through the rows
>
>2.) I tried to add the columns direclty to the datagrid,
>via the following code:
>
>...begin loop through the rows
>  Dim dgItem As DataGridItem
>  Dim dgCell As TableCell
>  dgItem = New DataGridItem(0, 0, ListItemType.Item)
>  dgCell = New TableCell
>  dgCell.ColumnSpan = AADataGridStores.Columns.Count
>  dgItem.Cells.Add(dgCell)
>  dgCell.Text = "Testing something..."
>  Dim t As Table = AADataGridStores.Controls(0)
>  t.Rows.AddAt(nRowPosition, dgItem)
>  nRowPosition = nRowPosition + 2
>...end loop through the rows
>
>But this doesnt work too and it gives the error:
>Specified argument was out of the range of valid values.
>Parameter name: index
>
>Now how I am supposed to add a new row which I can hide?
>Manually, I would place the row into a placeholder and
set
>the placeholder property either to true/false. But I am
>not getting how to do that in my situation. Can somebody
>please help me with this one?
>
>Thanks
>
>.
>
Author
23 Feb 2005 9:22 PM
Vishal
Hi Elton,

   But i got the error as provided in the first message. I
am adding the code right now in Init. Do you think thats
the problem? How should I hide the row? Basically, the
datagrid will contain a button in each row, which will
lets me hide or show the nested row. As said I would did
that with a placeholder, but dunno, how to do it in my
current situation. Any help is greatly appreciated.

Thanks


Show quoteHide quote
>-----Original Message-----
>Hi Vishal,
>
>I think basically your code of second option is OK. But,
>there two things you should take into consideration:
>
>1. Where to run the code? It should be after datagrid
data
>binding. It may be in PreRender.
>
>2. Loop scope. Depending on different setting, you may
>have or not Pager, Header, Footer. If you have any of
>them, you should count them and add rows beyond them.
>
>HTH
>
>Elton Wang
>elton_w***@hotmail.com
>
>
>
>
>>-----Original Message-----
>>Hello,
>>
>>   I have a datagrid, which creates the columns
>>dynamically based on the columns in the dataset. Now I
>>need to add an additional row for each exisiting row AND
>>hide that row, by default. This row will contain my
>>usercontrol, which I will add also dynamically.
>>Unfortunaly I am not able to do so. I tried two options:
>>
>>1.) I added the rows to the dataset and bound the
dataset
>>to the datagrid.
>>
>>- The problem however is, that I am not able to set the
>>span of that row somehow. I set it, but it doesnt take
>it.
>>
>>- The second problem is that I am not able to hide it. I
>>dont see any attributes property for the DataRow. Here
is
>>the code:
>>
>>...begin loop through the rows
>>  Dim NestedGridRow As DataRow = ds.Tables(0).NewRow
>>  Dim NestedCell As New TableCell
>>  NestedCell.ColumnSpan = 3 'ds.Tables(0).Columns.Count
>>  ds.Tables(0).Rows.InsertAt(NestedGridRow, nRowPosition)
>>  nRowPosition = nRowPosition + 2
>>...end loop through the rows
>>
>>2.) I tried to add the columns direclty to the datagrid,
>>via the following code:
>>
>>...begin loop through the rows
>>  Dim dgItem As DataGridItem
>>  Dim dgCell As TableCell
>>  dgItem = New DataGridItem(0, 0, ListItemType.Item)
>>  dgCell = New TableCell
>>  dgCell.ColumnSpan = AADataGridStores.Columns.Count
>>  dgItem.Cells.Add(dgCell)
>>  dgCell.Text = "Testing something..."
>>  Dim t As Table = AADataGridStores.Controls(0)
>>  t.Rows.AddAt(nRowPosition, dgItem)
>>  nRowPosition = nRowPosition + 2
>>...end loop through the rows
>>
>>But this doesnt work too and it gives the error:
>>Specified argument was out of the range of valid values.
>>Parameter name: index
>>
>>Now how I am supposed to add a new row which I can hide?
>>Manually, I would place the row into a placeholder and
>set
>>the placeholder property either to true/false. But I am
>>not getting how to do that in my situation. Can somebody
>>please help me with this one?
>>
>>Thanks
>>
>>.
>>
>.
>
Author
23 Feb 2005 9:54 PM
Elton Wang
Hi Vishal,

As I mentioned, your logic is OK.  But there are maybe two
things (maybe one of them maybe both of them) that cause
the trouble. One maybe is in wrong place to run your logic
(you can move code to Datagrid_PreRender). Another one is
from and to which exact row position you add those new
rows, I mean in

NRowPosition = ?startPositin
While (condition ?)

Currently you are using
dgCell.Text = "Testing something..."

You might use
dgCell.Controls.Add(yourcontrol)
in real situation.

HTH

Elton

Show quoteHide quote
>-----Original Message-----
>Hi Elton,
>
>   But i got the error as provided in the first message.
I
>am adding the code right now in Init. Do you think thats
>the problem? How should I hide the row? Basically, the
>datagrid will contain a button in each row, which will
>lets me hide or show the nested row. As said I would did
>that with a placeholder, but dunno, how to do it in my
>current situation. Any help is greatly appreciated.
>
>Thanks
>
>
>>-----Original Message-----
>>Hi Vishal,
>>
>>I think basically your code of second option is OK. But,
>>there two things you should take into consideration:
>>
>>1. Where to run the code? It should be after datagrid
>data
>>binding. It may be in PreRender.
>>
>>2. Loop scope. Depending on different setting, you may
>>have or not Pager, Header, Footer. If you have any of
>>them, you should count them and add rows beyond them.
>>
>>HTH
>>
>>Elton Wang
>>elton_w***@hotmail.com
>>
>>
>>
>>
>>>-----Original Message-----
>>>Hello,
>>>
>>>   I have a datagrid, which creates the columns
>>>dynamically based on the columns in the dataset. Now I
>>>need to add an additional row for each exisiting row
AND
>>>hide that row, by default. This row will contain my
>>>usercontrol, which I will add also dynamically.
>>>Unfortunaly I am not able to do so. I tried two options:
>>>
>>>1.) I added the rows to the dataset and bound the
>dataset
>>>to the datagrid.
>>>
>>>- The problem however is, that I am not able to set the
>>>span of that row somehow. I set it, but it doesnt take
>>it.
>>>
>>>- The second problem is that I am not able to hide it.
I
>>>dont see any attributes property for the DataRow. Here
>is
>>>the code:
>>>
>>>...begin loop through the rows
>>>  Dim NestedGridRow As DataRow = ds.Tables(0).NewRow
>>>  Dim NestedCell As New TableCell
>>>  NestedCell.ColumnSpan = 3 'ds.Tables(0).Columns.Count
>>>  ds.Tables(0).Rows.InsertAt(NestedGridRow,
nRowPosition)
>>>  nRowPosition = nRowPosition + 2
>>>...end loop through the rows
>>>
>>>2.) I tried to add the columns direclty to the
datagrid,
>>>via the following code:
>>>
>>>...begin loop through the rows
>>>  Dim dgItem As DataGridItem
>>>  Dim dgCell As TableCell
>>>  dgItem = New DataGridItem(0, 0, ListItemType.Item)
>>>  dgCell = New TableCell
>>>  dgCell.ColumnSpan = AADataGridStores.Columns.Count
>>>  dgItem.Cells.Add(dgCell)
>>>  dgCell.Text = "Testing something..."
>>>  Dim t As Table = AADataGridStores.Controls(0)
>>>  t.Rows.AddAt(nRowPosition, dgItem)
>>>  nRowPosition = nRowPosition + 2
>>>...end loop through the rows
>>>
>>>But this doesnt work too and it gives the error:
>>>Specified argument was out of the range of valid
values.
>>>Parameter name: index
>>>
>>>Now how I am supposed to add a new row which I can
hide?
>>>Manually, I would place the row into a placeholder and
>>set
>>>the placeholder property either to true/false. But I am
>>>not getting how to do that in my situation. Can
somebody
>>>please help me with this one?
>>>
>>>Thanks
>>>
>>>.
>>>
>>.
>>
>.
>
Author
23 Feb 2005 10:19 PM
Vishal
Hey Elton,

   thanks for responding. I will try to move the code but
what about hiding the row? How should I do that?


Show quoteHide quote
>-----Original Message-----
>Hi Vishal,
>
>As I mentioned, your logic is OK.  But there are maybe
two
>things (maybe one of them maybe both of them) that cause
>the trouble. One maybe is in wrong place to run your
logic
>(you can move code to Datagrid_PreRender). Another one is
>from and to which exact row position you add those new
>rows, I mean in
>
>NRowPosition = ?startPositin
>While (condition ?)
>
>Currently you are using
>dgCell.Text = "Testing something..."
>
>You might use
>dgCell.Controls.Add(yourcontrol)
>in real situation.
>
>HTH
>
>Elton
>
>>-----Original Message-----
>>Hi Elton,
>>
>>   But i got the error as provided in the first message.
>I
>>am adding the code right now in Init. Do you think thats
>>the problem? How should I hide the row? Basically, the
>>datagrid will contain a button in each row, which will
>>lets me hide or show the nested row. As said I would did
>>that with a placeholder, but dunno, how to do it in my
>>current situation. Any help is greatly appreciated.
>>
>>Thanks
>>
>>
>>>-----Original Message-----
>>>Hi Vishal,
>>>
>>>I think basically your code of second option is OK.
But,
>>>there two things you should take into consideration:
>>>
>>>1. Where to run the code? It should be after datagrid
>>data
>>>binding. It may be in PreRender.
>>>
>>>2. Loop scope. Depending on different setting, you may
>>>have or not Pager, Header, Footer. If you have any of
>>>them, you should count them and add rows beyond them.
>>>
>>>HTH
>>>
>>>Elton Wang
>>>elton_w***@hotmail.com
>>>
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>Hello,
>>>>
>>>>   I have a datagrid, which creates the columns
>>>>dynamically based on the columns in the dataset. Now I
>>>>need to add an additional row for each exisiting row
>AND
>>>>hide that row, by default. This row will contain my
>>>>usercontrol, which I will add also dynamically.
>>>>Unfortunaly I am not able to do so. I tried two
options:
>>>>
>>>>1.) I added the rows to the dataset and bound the
>>dataset
>>>>to the datagrid.
>>>>
>>>>- The problem however is, that I am not able to set
the
>>>>span of that row somehow. I set it, but it doesnt take
>>>it.
>>>>
>>>>- The second problem is that I am not able to hide it.
>I
>>>>dont see any attributes property for the DataRow. Here
>>is
>>>>the code:
>>>>
>>>>...begin loop through the rows
>>>>  Dim NestedGridRow As DataRow = ds.Tables(0).NewRow
>>>>  Dim NestedCell As New TableCell
>>>>  NestedCell.ColumnSpan = 3 'ds.Tables(0).Columns.Count
>>>>  ds.Tables(0).Rows.InsertAt(NestedGridRow,
>nRowPosition)
>>>>  nRowPosition = nRowPosition + 2
>>>>...end loop through the rows
>>>>
>>>>2.) I tried to add the columns direclty to the
>datagrid,
>>>>via the following code:
>>>>
>>>>...begin loop through the rows
>>>>  Dim dgItem As DataGridItem
>>>>  Dim dgCell As TableCell
>>>>  dgItem = New DataGridItem(0, 0, ListItemType.Item)
>>>>  dgCell = New TableCell
>>>>  dgCell.ColumnSpan = AADataGridStores.Columns.Count
>>>>  dgItem.Cells.Add(dgCell)
>>>>  dgCell.Text = "Testing something..."
>>>>  Dim t As Table = AADataGridStores.Controls(0)
>>>>  t.Rows.AddAt(nRowPosition, dgItem)
>>>>  nRowPosition = nRowPosition + 2
>>>>...end loop through the rows
>>>>
>>>>But this doesnt work too and it gives the error:
>>>>Specified argument was out of the range of valid
>values.
>>>>Parameter name: index
>>>>
>>>>Now how I am supposed to add a new row which I can
>hide?
>>>>Manually, I would place the row into a placeholder and
>>>set
>>>>the placeholder property either to true/false. But I
am
>>>>not getting how to do that in my situation. Can
>somebody
>>>>please help me with this one?
>>>>
>>>>Thanks
>>>>
>>>>.
>>>>
>>>.
>>>
>>.
>>
>.
>
Author
23 Feb 2005 11:04 PM
Vishal
Is OnPreRender and DataGrid_PreRender the same? I have
currently defined it in page like this:

Protected Overloads Sub OnPreRender()
....
end sub

Is that ok?


Show quoteHide quote
>-----Original Message-----
>Hi Vishal,
>
>As I mentioned, your logic is OK.  But there are maybe
two
>things (maybe one of them maybe both of them) that cause
>the trouble. One maybe is in wrong place to run your
logic
>(you can move code to Datagrid_PreRender). Another one is
>from and to which exact row position you add those new
>rows, I mean in
>
>NRowPosition = ?startPositin
>While (condition ?)
>
>Currently you are using
>dgCell.Text = "Testing something..."
>
>You might use
>dgCell.Controls.Add(yourcontrol)
>in real situation.
>
>HTH
>
>Elton
>
>>-----Original Message-----
>>Hi Elton,
>>
>>   But i got the error as provided in the first message.
>I
>>am adding the code right now in Init. Do you think thats
>>the problem? How should I hide the row? Basically, the
>>datagrid will contain a button in each row, which will
>>lets me hide or show the nested row. As said I would did
>>that with a placeholder, but dunno, how to do it in my
>>current situation. Any help is greatly appreciated.
>>
>>Thanks
>>
>>
>>>-----Original Message-----
>>>Hi Vishal,
>>>
>>>I think basically your code of second option is OK.
But,
>>>there two things you should take into consideration:
>>>
>>>1. Where to run the code? It should be after datagrid
>>data
>>>binding. It may be in PreRender.
>>>
>>>2. Loop scope. Depending on different setting, you may
>>>have or not Pager, Header, Footer. If you have any of
>>>them, you should count them and add rows beyond them.
>>>
>>>HTH
>>>
>>>Elton Wang
>>>elton_w***@hotmail.com
>>>
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>Hello,
>>>>
>>>>   I have a datagrid, which creates the columns
>>>>dynamically based on the columns in the dataset. Now I
>>>>need to add an additional row for each exisiting row
>AND
>>>>hide that row, by default. This row will contain my
>>>>usercontrol, which I will add also dynamically.
>>>>Unfortunaly I am not able to do so. I tried two
options:
>>>>
>>>>1.) I added the rows to the dataset and bound the
>>dataset
>>>>to the datagrid.
>>>>
>>>>- The problem however is, that I am not able to set
the
>>>>span of that row somehow. I set it, but it doesnt take
>>>it.
>>>>
>>>>- The second problem is that I am not able to hide it.
>I
>>>>dont see any attributes property for the DataRow. Here
>>is
>>>>the code:
>>>>
>>>>...begin loop through the rows
>>>>  Dim NestedGridRow As DataRow = ds.Tables(0).NewRow
>>>>  Dim NestedCell As New TableCell
>>>>  NestedCell.ColumnSpan = 3 'ds.Tables(0).Columns.Count
>>>>  ds.Tables(0).Rows.InsertAt(NestedGridRow,
>nRowPosition)
>>>>  nRowPosition = nRowPosition + 2
>>>>...end loop through the rows
>>>>
>>>>2.) I tried to add the columns direclty to the
>datagrid,
>>>>via the following code:
>>>>
>>>>...begin loop through the rows
>>>>  Dim dgItem As DataGridItem
>>>>  Dim dgCell As TableCell
>>>>  dgItem = New DataGridItem(0, 0, ListItemType.Item)
>>>>  dgCell = New TableCell
>>>>  dgCell.ColumnSpan = AADataGridStores.Columns.Count
>>>>  dgItem.Cells.Add(dgCell)
>>>>  dgCell.Text = "Testing something..."
>>>>  Dim t As Table = AADataGridStores.Controls(0)
>>>>  t.Rows.AddAt(nRowPosition, dgItem)
>>>>  nRowPosition = nRowPosition + 2
>>>>...end loop through the rows
>>>>
>>>>But this doesnt work too and it gives the error:
>>>>Specified argument was out of the range of valid
>values.
>>>>Parameter name: index
>>>>
>>>>Now how I am supposed to add a new row which I can
>hide?
>>>>Manually, I would place the row into a placeholder and
>>>set
>>>>the placeholder property either to true/false. But I
am
>>>>not getting how to do that in my situation. Can
>somebody
>>>>please help me with this one?
>>>>
>>>>Thanks
>>>>
>>>>.
>>>>
>>>.
>>>
>>.
>>
>.
>
Author
23 Feb 2005 11:07 PM
Vishal
Furtheremore isnt PreRender already to late? I mean will
it keep its viewstate?


Show quoteHide quote
>-----Original Message-----
>Hi Vishal,
>
>As I mentioned, your logic is OK.  But there are maybe
two
>things (maybe one of them maybe both of them) that cause
>the trouble. One maybe is in wrong place to run your
logic
>(you can move code to Datagrid_PreRender). Another one is
>from and to which exact row position you add those new
>rows, I mean in
>
>NRowPosition = ?startPositin
>While (condition ?)
>
>Currently you are using
>dgCell.Text = "Testing something..."
>
>You might use
>dgCell.Controls.Add(yourcontrol)
>in real situation.
>
>HTH
>
>Elton
>
>>-----Original Message-----
>>Hi Elton,
>>
>>   But i got the error as provided in the first message.
>I
>>am adding the code right now in Init. Do you think thats
>>the problem? How should I hide the row? Basically, the
>>datagrid will contain a button in each row, which will
>>lets me hide or show the nested row. As said I would did
>>that with a placeholder, but dunno, how to do it in my
>>current situation. Any help is greatly appreciated.
>>
>>Thanks
>>
>>
>>>-----Original Message-----
>>>Hi Vishal,
>>>
>>>I think basically your code of second option is OK.
But,
>>>there two things you should take into consideration:
>>>
>>>1. Where to run the code? It should be after datagrid
>>data
>>>binding. It may be in PreRender.
>>>
>>>2. Loop scope. Depending on different setting, you may
>>>have or not Pager, Header, Footer. If you have any of
>>>them, you should count them and add rows beyond them.
>>>
>>>HTH
>>>
>>>Elton Wang
>>>elton_w***@hotmail.com
>>>
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>Hello,
>>>>
>>>>   I have a datagrid, which creates the columns
>>>>dynamically based on the columns in the dataset. Now I
>>>>need to add an additional row for each exisiting row
>AND
>>>>hide that row, by default. This row will contain my
>>>>usercontrol, which I will add also dynamically.
>>>>Unfortunaly I am not able to do so. I tried two
options:
>>>>
>>>>1.) I added the rows to the dataset and bound the
>>dataset
>>>>to the datagrid.
>>>>
>>>>- The problem however is, that I am not able to set
the
>>>>span of that row somehow. I set it, but it doesnt take
>>>it.
>>>>
>>>>- The second problem is that I am not able to hide it.
>I
>>>>dont see any attributes property for the DataRow. Here
>>is
>>>>the code:
>>>>
>>>>...begin loop through the rows
>>>>  Dim NestedGridRow As DataRow = ds.Tables(0).NewRow
>>>>  Dim NestedCell As New TableCell
>>>>  NestedCell.ColumnSpan = 3 'ds.Tables(0).Columns.Count
>>>>  ds.Tables(0).Rows.InsertAt(NestedGridRow,
>nRowPosition)
>>>>  nRowPosition = nRowPosition + 2
>>>>...end loop through the rows
>>>>
>>>>2.) I tried to add the columns direclty to the
>datagrid,
>>>>via the following code:
>>>>
>>>>...begin loop through the rows
>>>>  Dim dgItem As DataGridItem
>>>>  Dim dgCell As TableCell
>>>>  dgItem = New DataGridItem(0, 0, ListItemType.Item)
>>>>  dgCell = New TableCell
>>>>  dgCell.ColumnSpan = AADataGridStores.Columns.Count
>>>>  dgItem.Cells.Add(dgCell)
>>>>  dgCell.Text = "Testing something..."
>>>>  Dim t As Table = AADataGridStores.Controls(0)
>>>>  t.Rows.AddAt(nRowPosition, dgItem)
>>>>  nRowPosition = nRowPosition + 2
>>>>...end loop through the rows
>>>>
>>>>But this doesnt work too and it gives the error:
>>>>Specified argument was out of the range of valid
>values.
>>>>Parameter name: index
>>>>
>>>>Now how I am supposed to add a new row which I can
>hide?
>>>>Manually, I would place the row into a placeholder and
>>>set
>>>>the placeholder property either to true/false. But I
am
>>>>not getting how to do that in my situation. Can
>somebody
>>>>please help me with this one?
>>>>
>>>>Thanks
>>>>
>>>>.
>>>>
>>>.
>>>
>>.
>>
>.
>
Author
24 Feb 2005 2:38 PM
Elton Wang
You are right. It seems the viewstate can't keep added
rows, even add them very early (Page_Load, right after
data binding). So once postback, it shows trouble. But it
can't be done befor data binding. Currently I don't know
how to figure it out. If you find solution, please share
your idea.

Elton

Show quoteHide quote
>-----Original Message-----
>Furtheremore isnt PreRender already to late? I mean will
>it keep its viewstate?
>
>
>>-----Original Message-----
>>Hi Vishal,
>>
>>As I mentioned, your logic is OK.  But there are maybe
>two
>>things (maybe one of them maybe both of them) that cause
>>the trouble. One maybe is in wrong place to run your
>logic
>>(you can move code to Datagrid_PreRender). Another one
is
>>from and to which exact row position you add those new
>>rows, I mean in
>>
>>NRowPosition = ?startPositin
>>While (condition ?)
>>
>>Currently you are using
>>dgCell.Text = "Testing something..."
>>
>>You might use
>>dgCell.Controls.Add(yourcontrol)
>>in real situation.
>>
>>HTH
>>
>>Elton
>>
>>>-----Original Message-----
>>>Hi Elton,
>>>
>>>   But i got the error as provided in the first
message.
>>I
>>>am adding the code right now in Init. Do you think
thats
>>>the problem? How should I hide the row? Basically, the
>>>datagrid will contain a button in each row, which will
>>>lets me hide or show the nested row. As said I would
did
>>>that with a placeholder, but dunno, how to do it in my
>>>current situation. Any help is greatly appreciated.
>>>
>>>Thanks
>>>
>>>
>>>>-----Original Message-----
>>>>Hi Vishal,
>>>>
>>>>I think basically your code of second option is OK.
>But,
>>>>there two things you should take into consideration:
>>>>
>>>>1. Where to run the code? It should be after datagrid
>>>data
>>>>binding. It may be in PreRender.
>>>>
>>>>2. Loop scope. Depending on different setting, you may
>>>>have or not Pager, Header, Footer. If you have any of
>>>>them, you should count them and add rows beyond them.
>>>>
>>>>HTH
>>>>
>>>>Elton Wang
>>>>elton_w***@hotmail.com
>>>>
>>>>
>>>>
>>>>
>>>>>-----Original Message-----
>>>>>Hello,
>>>>>
>>>>>   I have a datagrid, which creates the columns
>>>>>dynamically based on the columns in the dataset. Now
I
>>>>>need to add an additional row for each exisiting row
>>AND
>>>>>hide that row, by default. This row will contain my
>>>>>usercontrol, which I will add also dynamically.
>>>>>Unfortunaly I am not able to do so. I tried two
>options:
>>>>>
>>>>>1.) I added the rows to the dataset and bound the
>>>dataset
>>>>>to the datagrid.
>>>>>
>>>>>- The problem however is, that I am not able to set
>the
>>>>>span of that row somehow. I set it, but it doesnt
take
>>>>it.
>>>>>
>>>>>- The second problem is that I am not able to hide
it.
>>I
>>>>>dont see any attributes property for the DataRow.
Here
>>>is
>>>>>the code:
>>>>>
>>>>>...begin loop through the rows
>>>>>  Dim NestedGridRow As DataRow = ds.Tables(0).NewRow
>>>>>  Dim NestedCell As New TableCell
>>>>>  NestedCell.ColumnSpan = 3 'ds.Tables
(0).Columns.Count
Show quoteHide quote
>>>>>  ds.Tables(0).Rows.InsertAt(NestedGridRow,
>>nRowPosition)
>>>>>  nRowPosition = nRowPosition + 2
>>>>>...end loop through the rows
>>>>>
>>>>>2.) I tried to add the columns direclty to the
>>datagrid,
>>>>>via the following code:
>>>>>
>>>>>...begin loop through the rows
>>>>>  Dim dgItem As DataGridItem
>>>>>  Dim dgCell As TableCell
>>>>>  dgItem = New DataGridItem(0, 0, ListItemType.Item)
>>>>>  dgCell = New TableCell
>>>>>  dgCell.ColumnSpan = AADataGridStores.Columns.Count
>>>>>  dgItem.Cells.Add(dgCell)
>>>>>  dgCell.Text = "Testing something..."
>>>>>  Dim t As Table = AADataGridStores.Controls(0)
>>>>>  t.Rows.AddAt(nRowPosition, dgItem)
>>>>>  nRowPosition = nRowPosition + 2
>>>>>...end loop through the rows
>>>>>
>>>>>But this doesnt work too and it gives the error:
>>>>>Specified argument was out of the range of valid
>>values.
>>>>>Parameter name: index
>>>>>
>>>>>Now how I am supposed to add a new row which I can
>>hide?
>>>>>Manually, I would place the row into a placeholder
and
>>>>set
>>>>>the placeholder property either to true/false. But I
>am
>>>>>not getting how to do that in my situation. Can
>>somebody
>>>>>please help me with this one?
>>>>>
>>>>>Thanks
>>>>>
>>>>>.
>>>>>
>>>>.
>>>>
>>>.
>>>
>>.
>>
>.
>
Author
24 Feb 2005 6:22 PM
Vishal
I am discussing this problem with somebody at the GDN
forums:

http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx
?id=302261


Show quoteHide quote
>-----Original Message-----
>You are right. It seems the viewstate can't keep added
>rows, even add them very early (Page_Load, right after
>data binding). So once postback, it shows trouble. But it
>can't be done befor data binding. Currently I don't know
>how to figure it out. If you find solution, please share
>your idea.
>
>Elton
>
>>-----Original Message-----
>>Furtheremore isnt PreRender already to late? I mean will
>>it keep its viewstate?
>>
>>
>>>-----Original Message-----
>>>Hi Vishal,
>>>
>>>As I mentioned, your logic is OK.  But there are maybe
>>two
>>>things (maybe one of them maybe both of them) that
cause
>>>the trouble. One maybe is in wrong place to run your
>>logic
>>>(you can move code to Datagrid_PreRender). Another one
>is
>>>from and to which exact row position you add those new
>>>rows, I mean in
>>>
>>>NRowPosition = ?startPositin
>>>While (condition ?)
>>>
>>>Currently you are using
>>>dgCell.Text = "Testing something..."
>>>
>>>You might use
>>>dgCell.Controls.Add(yourcontrol)
>>>in real situation.
>>>
>>>HTH
>>>
>>>Elton
>>>
>>>>-----Original Message-----
>>>>Hi Elton,
>>>>
>>>>   But i got the error as provided in the first
>message.
>>>I
>>>>am adding the code right now in Init. Do you think
>thats
>>>>the problem? How should I hide the row? Basically, the
>>>>datagrid will contain a button in each row, which will
>>>>lets me hide or show the nested row. As said I would
>did
>>>>that with a placeholder, but dunno, how to do it in my
>>>>current situation. Any help is greatly appreciated.
>>>>
>>>>Thanks
>>>>
>>>>
>>>>>-----Original Message-----
>>>>>Hi Vishal,
>>>>>
>>>>>I think basically your code of second option is OK.
>>But,
>>>>>there two things you should take into consideration:
>>>>>
>>>>>1. Where to run the code? It should be after datagrid
>>>>data
>>>>>binding. It may be in PreRender.
>>>>>
>>>>>2. Loop scope. Depending on different setting, you
may
>>>>>have or not Pager, Header, Footer. If you have any of
>>>>>them, you should count them and add rows beyond them.
>>>>>
>>>>>HTH
>>>>>
>>>>>Elton Wang
>>>>>elton_w***@hotmail.com
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>>-----Original Message-----
>>>>>>Hello,
>>>>>>
>>>>>>   I have a datagrid, which creates the columns
>>>>>>dynamically based on the columns in the dataset. Now
>I
>>>>>>need to add an additional row for each exisiting row
>>>AND
>>>>>>hide that row, by default. This row will contain my
>>>>>>usercontrol, which I will add also dynamically.
>>>>>>Unfortunaly I am not able to do so. I tried two
>>options:
>>>>>>
>>>>>>1.) I added the rows to the dataset and bound the
>>>>dataset
>>>>>>to the datagrid.
>>>>>>
>>>>>>- The problem however is, that I am not able to set
>>the
>>>>>>span of that row somehow. I set it, but it doesnt
>take
>>>>>it.
>>>>>>
>>>>>>- The second problem is that I am not able to hide
>it.
>>>I
>>>>>>dont see any attributes property for the DataRow.
>Here
>>>>is
>>>>>>the code:
>>>>>>
>>>>>>...begin loop through the rows
>>>>>>  Dim NestedGridRow As DataRow = ds.Tables(0).NewRow
>>>>>>  Dim NestedCell As New TableCell
>>>>>>  NestedCell.ColumnSpan = 3 'ds.Tables
>(0).Columns.Count
>>>>>>  ds.Tables(0).Rows.InsertAt(NestedGridRow,
>>>nRowPosition)
>>>>>>  nRowPosition = nRowPosition + 2
>>>>>>...end loop through the rows
>>>>>>
>>>>>>2.) I tried to add the columns direclty to the
>>>datagrid,
>>>>>>via the following code:
>>>>>>
>>>>>>...begin loop through the rows
>>>>>>  Dim dgItem As DataGridItem
>>>>>>  Dim dgCell As TableCell
>>>>>>  dgItem = New DataGridItem(0, 0, ListItemType.Item)
>>>>>>  dgCell = New TableCell
>>>>>>  dgCell.ColumnSpan = AADataGridStores.Columns.Count
>>>>>>  dgItem.Cells.Add(dgCell)
>>>>>>  dgCell.Text = "Testing something..."
>>>>>>  Dim t As Table = AADataGridStores.Controls(0)
>>>>>>  t.Rows.AddAt(nRowPosition, dgItem)
>>>>>>  nRowPosition = nRowPosition + 2
>>>>>>...end loop through the rows
>>>>>>
>>>>>>But this doesnt work too and it gives the error:
>>>>>>Specified argument was out of the range of valid
>>>values.
>>>>>>Parameter name: index
>>>>>>
>>>>>>Now how I am supposed to add a new row which I can
>>>hide?
>>>>>>Manually, I would place the row into a placeholder
>and
>>>>>set
>>>>>>the placeholder property either to true/false. But I
>>am
>>>>>>not getting how to do that in my situation. Can
>>>somebody
>>>>>>please help me with this one?
>>>>>>
>>>>>>Thanks
>>>>>>
>>>>>>.
>>>>>>
>>>>>.
>>>>>
>>>>.
>>>>
>>>.
>>>
>>.
>>
>.
>
Author
23 Feb 2005 11:13 PM
Vishal
I added the code to the PreRender and now my complete dg
doesnt show up...

Private Sub AADataGridStores_PreRender(ByVal sender As
Object, ByVal e As System.EventArgs) Handles
AADataGridStores.PreRender
        CreateColumns()
    End Sub


Show quoteHide quote
>-----Original Message-----
>Hi Vishal,
>
>As I mentioned, your logic is OK.  But there are maybe
two
>things (maybe one of them maybe both of them) that cause
>the trouble. One maybe is in wrong place to run your
logic
>(you can move code to Datagrid_PreRender). Another one is
>from and to which exact row position you add those new
>rows, I mean in
>
>NRowPosition = ?startPositin
>While (condition ?)
>
>Currently you are using
>dgCell.Text = "Testing something..."
>
>You might use
>dgCell.Controls.Add(yourcontrol)
>in real situation.
>
>HTH
>
>Elton
>
>>-----Original Message-----
>>Hi Elton,
>>
>>   But i got the error as provided in the first message.
>I
>>am adding the code right now in Init. Do you think thats
>>the problem? How should I hide the row? Basically, the
>>datagrid will contain a button in each row, which will
>>lets me hide or show the nested row. As said I would did
>>that with a placeholder, but dunno, how to do it in my
>>current situation. Any help is greatly appreciated.
>>
>>Thanks
>>
>>
>>>-----Original Message-----
>>>Hi Vishal,
>>>
>>>I think basically your code of second option is OK.
But,
>>>there two things you should take into consideration:
>>>
>>>1. Where to run the code? It should be after datagrid
>>data
>>>binding. It may be in PreRender.
>>>
>>>2. Loop scope. Depending on different setting, you may
>>>have or not Pager, Header, Footer. If you have any of
>>>them, you should count them and add rows beyond them.
>>>
>>>HTH
>>>
>>>Elton Wang
>>>elton_w***@hotmail.com
>>>
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>Hello,
>>>>
>>>>   I have a datagrid, which creates the columns
>>>>dynamically based on the columns in the dataset. Now I
>>>>need to add an additional row for each exisiting row
>AND
>>>>hide that row, by default. This row will contain my
>>>>usercontrol, which I will add also dynamically.
>>>>Unfortunaly I am not able to do so. I tried two
options:
>>>>
>>>>1.) I added the rows to the dataset and bound the
>>dataset
>>>>to the datagrid.
>>>>
>>>>- The problem however is, that I am not able to set
the
>>>>span of that row somehow. I set it, but it doesnt take
>>>it.
>>>>
>>>>- The second problem is that I am not able to hide it.
>I
>>>>dont see any attributes property for the DataRow. Here
>>is
>>>>the code:
>>>>
>>>>...begin loop through the rows
>>>>  Dim NestedGridRow As DataRow = ds.Tables(0).NewRow
>>>>  Dim NestedCell As New TableCell
>>>>  NestedCell.ColumnSpan = 3 'ds.Tables(0).Columns.Count
>>>>  ds.Tables(0).Rows.InsertAt(NestedGridRow,
>nRowPosition)
>>>>  nRowPosition = nRowPosition + 2
>>>>...end loop through the rows
>>>>
>>>>2.) I tried to add the columns direclty to the
>datagrid,
>>>>via the following code:
>>>>
>>>>...begin loop through the rows
>>>>  Dim dgItem As DataGridItem
>>>>  Dim dgCell As TableCell
>>>>  dgItem = New DataGridItem(0, 0, ListItemType.Item)
>>>>  dgCell = New TableCell
>>>>  dgCell.ColumnSpan = AADataGridStores.Columns.Count
>>>>  dgItem.Cells.Add(dgCell)
>>>>  dgCell.Text = "Testing something..."
>>>>  Dim t As Table = AADataGridStores.Controls(0)
>>>>  t.Rows.AddAt(nRowPosition, dgItem)
>>>>  nRowPosition = nRowPosition + 2
>>>>...end loop through the rows
>>>>
>>>>But this doesnt work too and it gives the error:
>>>>Specified argument was out of the range of valid
>values.
>>>>Parameter name: index
>>>>
>>>>Now how I am supposed to add a new row which I can
>hide?
>>>>Manually, I would place the row into a placeholder and
>>>set
>>>>the placeholder property either to true/false. But I
am
>>>>not getting how to do that in my situation. Can
>somebody
>>>>please help me with this one?
>>>>
>>>>Thanks
>>>>
>>>>.
>>>>
>>>.
>>>
>>.
>>
>.
>