Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
360
ASP.NET validators not working when WebDataGrid is inside a WebSplitter pane
posted

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%">

<Template>

<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">

<Behaviors>

<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">

<ColumnSettings>

<ig:RowAddingColumnSetting ColumnKey="Name" ValidatorID="ReqValidator" />

</ColumnSettings>

</ig:RowAdding>

</Behaviors>

</ig:EditingCore>

</Behaviors>

</ig:WebDataGrid>

</Template>

</ig:SplitterPane>

</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

WebApplication2.zip