Note that there are some explanatory texts on larger screens.

plurals
  1. PORadioButtonList inside gridview - Server side code too slow, can I do it on the client?
    primarykey
    data
    text
    <p>I've got a radio button list inside a grid view like so:</p> <pre><code>&lt;asp:GridView ID="gvLineItems" runat="server"&gt; &lt;asp:TemplateField&gt; &lt;asp:RadioButtonList ToolTip="Please provide an answer to the method." AutoPostBack="true" RepeatDirection="Horizontal" ID="rbAnswer" runat="server" SelectedValue='&lt;%# DataBinder.Eval(Container, "DataItem.AnswerID")%&gt;' OnSelectedIndexChanged="rbAnswer_SelectedIndexChanged"&gt; &lt;asp:ListItem Text="Yes" Value="Yes" style="color:green;"&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Text="No" Value="No" style="color:red;"&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Text="N/A" Value="N/A" style="color:gray;"&gt;&lt;/asp:ListItem&gt; &lt;asp:ListItem Value="" Text="" style="display: none" /&gt; &lt;/asp:RadioButtonList&gt; &lt;/asp:TemplateField&gt; &lt;/asp:GridView&gt; </code></pre> <p>Currently when you change the selection of the radio button it calls <code>rbAnswer_SelectedIndexChanged()</code> in code behind...</p> <p>The code behind this (and I will shorten it), is something to the effect of:</p> <pre><code> protected void rbAnswer_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow gr = (GridViewRow)((DataControlFieldCell)((RadioButtonList)sender).Parent).Parent; RadioButtonList rbl = (RadioButtonList)gr.FindControl("rbAnswer"); //since the answer changed set some hidden fields as being changed... HtmlInputHidden hiddenFieldAnswered = (HtmlInputHidden)gr.FindControl("hdnAnswered"); hiddenFieldAnswered.Value = "1"; HtmlInputHidden hiddenField = (HtmlInputHidden)gr.FindControl("hdnIsChanged"); hiddenField.Value = "1"; Panel p; p = (Panel)gr.FindControl("pnlAnswer"); switch (rbl.SelectedItem.Text) { case "No": gr.Cells[0].BackColor = System.Drawing.Color.Red; p.Visible = true; break; case "Yes": gr.Cells[0].BackColor = System.Drawing.Color.Green; p.Visible = false; break; case "N/A": gr.Cells[0].BackColor = System.Drawing.Color.Gray; p.Visible = false; break; default: gr.Cells[0].BackColor = System.Drawing.Color.Transparent; p.Visible = false; break; } } </code></pre> <p>Basically if you select an answer it changes the color of a cell in the gridview and it either hides or unhides a panel. Doing this as back end code causes a big delay in the application. Can I do this in jquery? If so how do I access the radiobuttonlist, the answer, the panel, and a way to change the color of the first cell (<code>gr.cells[0].backcolor</code>) in jquery?</p> <p>If I do this all on the client side it may increase the usability for the end users, they are complaining right now it is too slow.</p>
    singulars
    1. This table or related slice is empty.
    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