Note that there are some explanatory texts on larger screens.

plurals
  1. PODropDownList.SelectedIndexChanged renders a code generated GridView incorrectly (doubles, triples, etc...)
    primarykey
    data
    text
    <p>I have a dropdownlist that controls the contents of 3 gridview controls. These are used in a webpart. However, every time the selectedindexchanged method of the dropdownlist fires an event, the contents of the dependent gridviews adds another rendering of a gridview. Hence, it doubles and even triples the contents of those gridviews.</p> <p>I have the following codes:</p> <p>->for the CreatChildControls method:</p> <pre><code>ProfileGrid(_gridProf, _dtProf, _infoObj, _column, _imgColumn, _ddl, _strConn, _id); Controls.Add(_gridProf); Controls.Add(new LiteralControl("&lt;br /&gt;")); PhysicalGrid(_gridPhys, _dtPhys, _infoObj, _column, _ddl, _strConn, _id); Controls.Add(_gridPhys); Controls.Add(new LiteralControl("&lt;br /&gt;")); LabGrid(_gridLab, _dtLab, _infoObj, _column, _ddl, _strConn, _id); Controls.Add(_gridLab); Controls.Add(new LiteralControl("&lt;br /&gt;")); </code></pre> <p>->for the SelectedIndexChanged method:</p> <pre><code>private void ddl_SelectedIndexChanged(object sender, EventArgs e) { ProfileGrid(_gridProf, _dtProf, _infoObj, _column, _imgColumn, _ddl, _strConn, _id); PhysicalGrid(_gridPhys, _dtPhys, _infoObj, _column, _ddl, _strConn, _id); LabGrid(_gridLab, _dtLab, _infoObj, _column, _ddl, _strConn, _id); } </code></pre> <p>->for one of the GridView Controls:</p> <pre><code>private void ProfileGrid(GridView grid, DataTable dt, InfoAccess infoObj, BoundField column, ImageField imgColumn, DropDownList ddl, string strConn, string id) { string query = "exec spr_VITALITY_SCORE '" + id + "', '" + (ddl.SelectedValue == "" ? DateTime.Now.Year.ToString() : ddl.SelectedValue.ToString()) + "'"; infoObj.StrConn = strConn; dt = infoObj.SQLResult(query); grid.DataSource = dt; column.DataField = "SCORE"; column.HeaderText = "Score"; grid.Columns.Add(column); imgColumn.DataImageUrlField = "VITALITY_COLOR"; imgColumn.DataImageUrlFormatString = "../../Style%20Library/OHImages/{0}"; imgColumn.HeaderText = "Vitality Color"; grid.Columns.Add(imgColumn); column = new BoundField(); column.DataField = "VITALITY_DEFINITION"; column.HeaderText = "Vitality Definition"; grid.Columns.Add(column); column = new BoundField(); column.DataField = "REMARKS"; column.HeaderText = "Remarks"; grid.Columns.Add(column); DesignGrid(_gridProf); _gridProf.Attributes.Add("Style", "text-align:center;"); } </code></pre> <p>The DesignGrid method only defines the attributes of the gridviews. Can anyone please assist me on this incorrect rendering problem? Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload