This is a migrated thread and some comments may be shown as answers.

Validating Gridview Row

0 Answers 32 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Prabhu
Top achievements
Rank 1
Prabhu asked on 27 Feb 2012, 03:18 PM
Hi,
I have a gridview and the columns in that grid are dynamically generated at runtime. Now I need to validate those columns in button click.
Since all the columns are created dynamically, i created a button dynamically with the help of the following code.

GridViewDataColumn Env1 = new GridViewDataColumn();
            Env1.Header = "Stop Timer";
            Env1.UniqueName = "btnStopTimer";
            StringBuilder CellETemp = new StringBuilder();
            CellETemp.Append("<DataTemplate ");

            CellETemp.Append("xmlns='http://schemas.microsoft.com/winfx/");
            CellETemp.Append("2006/xaml/presentation' ");

            CellETemp.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' ");
            CellETemp.Append("xmlns:basics='clr-namespace:System.Windows.Controls;");

            CellETemp.Append("assembly=System.Windows.Controls' >");
            CellETemp.Append("<StackPanel Orientation='Horizontal' HorizontalAlignment='Left' >");
            CellETemp.Append(" <Button x:Name='BtnStop1' Height='25' HorizontalAlignment='Left' ");
            CellETemp.Append(" Margin='5' ");
            CellETemp.Append(" Content='Stop Timer' />");
            CellETemp.Append("</StackPanel>");
            CellETemp.Append("</DataTemplate>");
            Env1.CellTemplate = (DataTemplate)XamlReader.Load(CellETemp.ToString());
            grdProcessLog.Columns.Add(Env1);
Now  I need to do an insert the data when the button is clicked and before that I need to validate the columns.
I do not need the same to be done in roweditended event, I want the operation t be done in the button click event. it seems that we cannot have the event handler. is there a work around for that?

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Prabhu
Top achievements
Rank 1
Share this question
or