c# - Validating Entries in an ASP.NET GridView without JavaScript -


background

I have a gridView where in column 1 The input depends on input column 2 .

  • If a user enters a , then Column2 will be in a system in code Column 1 .

Assumptions are implemented using Regexs and custom verification. I like a verification solution that does not use JavaScript.

 | Column1 Column2. __________________ | | Y N __________________ | En | Y __________________ | En | N 

question

How can I verify these entries in gridview without the use of JavaScript?

"itemprop =" text ">

You can use the radio button and the 'Template' column with a GridView feature. GridView markup will look like this:

  & lt; ASP: GridView id = "gvTest" runat = "server" AutoGenerateColumns = "false" OnRowDataBound = "gvTest_RowDataBound" & gt; & Lt; Columns & gt; & Lt; Asp: TemplateField Header Text = "Column 1" & gt; & Lt; ItemTemplate & gt; & Lt; ASP: Radiobutton ID = "RBSEE1 1" runat = "server" text = "" /> & Lt; / ItemTemplate & gt; & Lt; / ASP: TemplateField & gt; & Lt; Asp: TemplateField Header Text = "Column 2" & gt; & Lt; ItemTemplate & gt; & Lt; ASP: Radiobutton ID = "RBSSET2" runat = "server" text = "" /> & Lt; / ItemTemplate & gt; & Lt; / ASP: TemplateField & gt; & Lt; / Column & gt; & Lt; / ASP: GridView & gt;  

The trick is so that the result of which is that each row of the grid is treated as a radio button group from the browser correctly setting the 'GroupName' property of each radio button Will be done for This is where the 'OnRowDataBound' handler specified on the grid comes in play. The 'GvTest_RowDataBound' handler can be something like the definition of:

  protected zero gvTest_RowDataBound (Object Sender, GridViewRowEventArgs e) {if (e.Row.RowType == DataControlRowType.DataRow) {RadioButton RB1 = (Radiobutan) E.R.FundControl ("RBSEE1"); Radiobutan RB2 = (Radiobutan) E.R.FundControl ("RBSEE2"); Rb1.GroupName = rb2.GroupName = string.Format ("Select_ {0}", E.R.ro Index); }}  

You are going to ensure that the browser treats them as a group by adding line pointer to the group's name for each button of the radio and just one row per line Choosing a value will result in something similar:


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -