none
Quiero agregar un boton al final de una tabla llamada TRES. RRS feed

  • Debate general

  •  

    Tengo el siguiente codigo que me crea las tablas perfectamente. Este boton  que quiero crear en tiempo de ejecucion debe utilizar el valor de la ultima columna de esta tabla para hacer una consulta que estara en un metodo. Si me pueden ayudar con este problemita muchas gracias..

    private void creatablas()
            {
                SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["LicenciasConnectionString2"].ConnectionString);

                connection.Open();
                using (SqlCommand command = new SqlCommand("spConsultaInternaParaVerificacion", connection))
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.Parameters.AddWithValue("@cedula", txtCedula.Text);
                    command.Parameters.AddWithValue("@BaseDatos", Int32.Parse(ddlTipoPersona.SelectedValue));
                    SqlDataReader reader = command.ExecuteReader();
                    do
                    {
                        if (!reader.HasRows) continue;
                        Panel panel = new Panel();
                        panel.ScrollBars = ScrollBars.Horizontal;
                        Table table = new Table();
                        //table.CssClass = "";
                        table.CssClass = "table table-striped table-bordered table-hover datatable";//"responstable";
                        TableHeaderRow rowHeader = new TableHeaderRow();
                        rowHeader.CssClass = "thead";
                        rowHeader.CssClass = "";
                        List<String> columns = new List<String>();
                        for (int i = 0; i < reader.FieldCount; i++)
                        {
                            columns.Add(reader.GetName(i));
                        }
                        foreach (string column in columns)
                        {
                            if (column.ToLower() == "tabla") continue;
                            TableHeaderCell cell = new TableHeaderCell();
                            cell.Text = "" + column;
                            rowHeader.Cells.Add(cell);
                        }
                        table.Rows.Add(rowHeader);
                        string tabla = "";
                        while (reader.Read())
                        {
                            tabla = (string)reader["Tabla"];
                            if ((tabla == "UNO" || tabla == "DOS"))
                            {
                                if (Session["Perfil"].ToString() != "20" && Session["Perfil"].ToString() != "21")
                                    continue;
                            }

                            TableRow trow = new TableRow();
                            trow.CssClass = "";
                            int count = 0;
                            foreach (string column in columns)
                            {
                                count++;
                                if (column.ToLower() == "tabla") continue;
                                TableCell cell = new TableCell();
                                string datatype = reader.GetDataTypeName(count - 1);
                                if (datatype.ToLower() == "image")
                                {
                                    Image imag = new Image();
                                    try
                                    {
                                        imag.ImageUrl = TempImageUrl((byte[])reader[column]);
                                    }
                                    catch
                                    {
                                        //ignored
                                    }
                                    cell.Controls.Add(imag);
                                }
                                else
                                {
                                    try
                                    {
                                        cell.Text = Convert.ToString(reader[column] ?? "");
                                    }
                                    catch
                                    {
                                        cell.Text = "";
                                    }
                                }
                                trow.Cells.Add(cell);
                            }
                            table.Rows.Add(trow);
                        }

                        if ((tabla == "UNO" || tabla == "DOS"))
                        {
                            if (Session["Perfil"].ToString() != "20" && Session["Perfil"].ToString() != "21")
                                continue;
                        }
                        panel.CssClass = "panelHolder";
                        Panel titlePanel = new Panel();
                        titlePanel.CssClass = "titlePanel";
                        Label textTitle = new Label();
                        textTitle.Text = tabla.ToUpper();
                        titlePanel.Controls.Add(textTitle);
                        panel.Controls.Add(titlePanel);
                        panel.Controls.Add(table);
                        tablePlaceholder.Controls.Add(panel);
                        Image img = new Image();
                    } while (reader.NextResult());
                }
                connection.Close();
            }
    martes, 23 de mayo de 2017 15:02