Hello!
We're having problems with validation in a WebDataGrid that come from using a WebSplitter. We wish to validate on the client side via ASP.NET validators (we could use JavaScript, but since our grid contents change dynamically, so we'd rather like to plug in the fitting validators in the code-behind). The problem is: the ASP.NET validators don't work at all with your WebDataGrid as soon as we put it inside a WebSplitter pane. I guess we may have missed something in order to make it work together with the splitter, or it just doesn't all. In any case, I will post a minimal example here and also attach it as a Visual Studio project in the hope of getting it to work with your aid :-) Or find some other workaround at least.
We are using the Service Release version 2011 of the 14.1 CLR 4.5 IG components in VS20013 with Update 2; our browser is IE10, the OS is Win7 64 bit. This is the relevant part of the .aspx file:
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<ig:WebSplitter ID="MasterDetailSplitter" runat="server" Height="100%" Width="100%" Orientation="Vertical">
<Panes>
<ig:SplitterPane Size="10%" runat="server">
<Template>
</Template>
</ig:SplitterPane>
<ig:SplitterPane runat="server" Size="90%">
<asp:RequiredFieldValidator ID="ReqValidator" runat="server" ControlToValidate="WebDataGrid1" ForeColor="Red" ErrorMessage="fehlt" ValidationGroup="grp" />
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Width="100%" Height="300px" AutoGenerateColumns="false" DataKeyFields="ID">
<Columns>
<ig:BoundDataField Key="Name" DataFieldName="Name" Header-Text="Name" />
<ig:BoundDataField Key="Age" DataFieldName="Age" Header-Text="Age" />
</Columns>
<Behaviors>
<ig:Activation />
<ig:Selection CellClickAction="Row" RowSelectType="Single" />
<ig:RowSelectors RowNumbering="true" />
<ig:EditingCore BatchUpdating="true" AutoCRUD="false">
<ig:CellEditing EditModeActions-MouseClick="Double">
<ColumnSettings>
<ig:EditingColumnSetting ColumnKey="Name" ValidatorID="ReqValidator" />
</ColumnSettings>
</ig:CellEditing>
<ig:RowAdding EditModeActions-MouseClick="Single" EditModeActions-EnableOnActive="true" Alignment="Top">
<ig:RowAddingColumnSetting ColumnKey="Name" ValidatorID="ReqValidator" />
</ig:RowAdding>
</Behaviors>
</ig:EditingCore>
</ig:WebDataGrid>
</Panes>
</ig:WebSplitter>
In the code-behind, I just create some sample data by hand and bind it to the grid (that everything is just re-created on postback doesn't matter, since the problem is about client-side issues when adding/editing rows anyway; it's just to have some data ready).
protected void Page_Load(object sender, EventArgs e)
{
List<Person> people = new List<Person>();
people.Add(new Person { ID = 1, Name = "aa" });
people.Add(new Person { ID = 2, Name = "bb" });
people.Add(new Person { ID = 3, Name = "cc" });
WebDataGrid1.DataSource = people;
WebDataGrid1.DataBind();
}
public class Person
public int ID { get; set; }
public string Name { get; set; }
public int Age { get; set; }
Also, I had to add an option to the web.config, though this isn't needed in the actual project where it still doesn't work, so I doubt it has anything to do with the validators not working at all, but just to be sure:
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
So basically, nothing happens at all when I'm in the RowAdding column "Name", enter nothing, and try to leave the column. As soon as I comment out the whole WebSplitter and only have the ScriptManager and WebDataGrid, it all works fine (that is, I can't leave the textbox in the column, and a red error "fehlt" is shown). The splitter somehow kills the connection between the grid and the RequiredFieldValidator (or any other validator, for that matter). Is there any way around this behaviour? We really need those validators to work!
In the attached VS project, note that the splitter should be commented out, and thus everything working. If you uncomment it again, the missing behaviour should show. Thank you very much in advance! Johannes
Hi Johannes,
Upon further investigation, we found that since the RequiredValidator is in a Splitter template, its runtime ID becomes MasterDetailSplitter_tmpl0_ReqValidator, instead of just "ReqValidator". On the other hand, the ValidatorID of the editing column setting is always "ReqValidator", it's a fixed string. To resolve this, you need to either change that to "MasterDetailSplitter_tmpl0_ReqValidator", or set the ValidatorID of the column settings in a PreRender event handler for the grid, example:protected void WebDataGrid1_PreRender(object sender, EventArgs e){ WebDataGrid1.Behaviors.EditingCore.Behaviors.CellEditing.ColumnSettings["Name"].ValidatorID = ReqValidator.ClientID;}
Please let me know if you have any questions regarding this matter.
Hello Jose,
thanks for responding! I will follow this thread in hope of a solution or workaround.
Greetings
Johannes
Thank you for posting on our forums.
I have investigated the issue regarding RequiredFieldValidator doesn't validate cells if WebDataGrid is inside WebSplitter. I have asked our Product Development to examine this further. To ensure that it will receive attention, I have logged this behavior in our internal tracking system with a Development ID of 174650. The next step will be for a developer to review my investigation and confirm my findings or to offer a fix, or other resolution.
I will be sure to update this post with the resolution as soon as it becomes available.