Hello there,
in reference to my other question, subdatagrid, I have a problem calling multiple times the visible attribute:
When the user presses a button, I show the datagrid with
dgrIndRoleAttributes.Visible = true:
After pressing the button again, I just redo this with the
dgrIndRoleAttributes.Visible = false;
If I press the button again, so I want visible = true again, I get the error that the control with the same ID allready exists. Does Visible = False remove the control or does it just set the CSS?
Is there a bug in my code which causes such error or should I not use this property on that way?
Thanks for your response
Matthias
Hello Matthias,
The visibility property just affects the visibility of the control, but the control is still in the Page’s controls collection, so it should not be re-added/created on postback.
Thanks,
Olga Kerchentseva
ASP.NET Principal Software Engineer
Infragistics, Inc.
Hello Olga,
I'm not readding anything from the code behind. Does Visible = true readd the control? Would it be easier to add a css class collapsed?
Thanks
Hi Matthias,
You can add a css class with a display: none, setting and achieve the same thing. If you are not recreating the control on postback I would have to see your code to see why you are getting the error.
Olga
I changed the way we're showing it, so the problem has solved itself.
If I need to check this again, I'll reopen the case.
Thanks for your response.
Were you able to reproduce this issue with the sample that Olga provided?
Hi,
I am sorry I was not able to reproduce the issue. Attached is a sample website I build based on the code you posted. Can you reproduce the issue with my attached website? If not can you changed the attached website so it does reproduce the issue without using custom data/controls which I do not access to (or add those to the website as well) and repost it.
To run the website please change the dll version of the Infragistics dll in the Web.Config and aspx to the version that you are using. The styles directory is currently set to "http://localhost/ig_res12.1" in the Web.config if this is not where you have your styles installed please change this as well.
Thank you,
I made some tests, its definitly the header template.
Here is the whole grid: <ig:WebDataGrid ID="dgrIndRoleAttributes" runat="server" Height="350px" Width="100%" Visible="false" ShowHeader="true" AutoGenerateColumns="False" PageSize="4" CellPadding="0" CssClass="aspGrid" EnableViewState="true"> <Behaviors> <ig:EditingCore> <Behaviors> <ig:RowAdding> <AddNewRowClientEvents /> <EditModeActions EnableF2="false" /> </ig:RowAdding> </Behaviors> </ig:EditingCore> </Behaviors> <Columns> <ig:BoundDataField Hidden="true" Key="bdIndRoleAttributeId" DataFieldName="IR_ATTR_ID"> </ig:BoundDataField> <ig:TemplateDataField Header-Text="Description" Key="IndRoleAttribDesc" Width="50%"> <ItemTemplate> <stgwc:DropDown runat="server" ID="ddlIndRoleAttribDescr"> </stgwc:DropDown> </ItemTemplate> </ig:TemplateDataField> <ig:TemplateDataField Header-Text="Value" Key="IndRoleAttribVal" Width="50%"> <ItemTemplate> <stgwc:TextEdit runat="server" ID="txtIndRoleAttribValue"> </stgwc:TextEdit> </ItemTemplate> </ig:TemplateDataField> <ig:TemplateDataField Header-Text="Action" Key="IndRoleAttribAction" Width="50px"> <HeaderTemplate> <%-- <stgwc:ImageLinkButton runat="server" ID="btnCreateNewAttribute" ImageUrl="~/Images/base/Icons/16x16/add2.png" ToolTip="Add new Attribute" CommandName="Create" /> <stgwc:ImageLinkButton runat="server" ID="btnSaveAllAttributes" ImageUrl="~/Images/base/Icons/16x16/disk_green.png" ToolTip="Save all Attributes" CommandName="Save" /> <stgwc:ImageLinkButton runat="server" ID="btnCancelChanges" ImageUrl="~/Images/base/Icons/16x16/undo.png" CommandName="Cancel" ToolTip="Discard changes" />--%> </HeaderTemplate> <ItemTemplate> <stgwc:ImageLinkButton runat="server" ID="btnDeleteAttribute" ImageUrl="~/Images/base/Icons/16x16/delete2.png" ToolTip="Delete this Attribute" CommandName="Delete" CommandArgument='<%# Bind("IR_ATTR_ID") %>' /> </ItemTemplate> </ig:TemplateDataField> </Columns> </ig:WebDataGrid>
As you can see, I commented the buttons out, just to have an empty header template field.
If I remove this too, it works proper.
I guess it has something to do with the method I reload the data at page_load:
private void LoadIndRoleAttributes() { if (Session[Constants.Session.IndRoleId.ToString()] == null) return; long indRoleId = Convert.ToInt64(Session[Constants.Session.IndRoleId.ToString()]); if (Session[TMP] == null) { FastApplication.CallFacade<IIndRole>( facade => { Session[TMP] = facade.GetIndRoleAttributes(r => r.INDROLE_ID == indRoleId); }); } dgrIndRoleAttributes.ClearDataSource(); dgrIndRoleAttributes.Rows.Clear(); dgrIndRoleAttributes.DataSource = (Session[TMP] as List<INDROLE_ATTRIBUTE>); dgrIndRoleAttributes.DataBind(); }
So far I can't see anything special: I clear the datasource, I clear the rows, then I set the source and bind it.
Can you reproduce it? Is it a bug from the datagrid?