asp: GridView Does not update data

1

I have a problem with a asp:GridView that is not updating data, in HTML I have the following:

<asp:GridView ID="ResultadosTest" runat="server" CssClass="table table-bordered bs-table" AutoGenerateColumns="false" EmptyDataText="No existen datos que mostrar" >
    <Columns>
        <asp:BoundField DataField="NombreServicio" HeaderText="Seccion" ReadOnly="True" />
        <asp:BoundField DataField="Resultado" HeaderText="Resultado" ReadOnly="True" />
    </Columns>
</asp:GridView>

And in Code behind when loading the page:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        DataTable table = new DataTable();
        table.Columns.AddRange(new DataColumn[2] { new DataColumn("NombreServicio", typeof(string)), new DataColumn("Resultado", typeof(bool)) });
        ResultadosTest.DataSource = table;
        ResultadosTest.DataBind();
    }
}

Later with a button that gathers data and fills a DataTable (it was verified that the DataTable if it brings data):

protected void GoPruebas_Click(object sender, EventArgs e)
{
     ResultadosTest.DataSource = ValidacionesServicio(chkBoxAmbientes.Items[i].Value).Result;
     ResultadosTest.DataBind();
}

But the data is not shown, what is going wrong?

    
asked by Archer_A 09.02.2017 в 19:29
source

1 answer

0

I tried your code to some extent and it works, can you try creating a table with literal values and assigning it to the DataSource of the gridView instead of using the ValidationsServices method?

Something like this:

protected void Button1_Click(object sender, EventArgs e)
    {
        table.Columns.AddRange(new DataColumn[2] { new DataColumn("NombreServicio", typeof(string)), new DataColumn("Resultado", typeof(bool)) });
        table.Rows.Add("Prueba servicio","true");
        ResultadosTest.DataSource = table;
        ResultadosTest.DataBind();
    }
    
answered by 23.02.2017 в 00:28