i'm using a grid view with both radiobuttion and text box to answer some questions with comments
aspx page for that control is
<asp:GridView ID="gvOccupancy" runat="server" AutoGenerateColumns="False" CssClass="gridView" DataKeyNames="Qid" Width="100%">
<Columns>
<asp:boundfield datafield="QNo" headerText="#"/>
<asp:boundfield datafield="question" />
<asp:boundfield datafield="risk_rating" HeaderText="Level" ItemStyle-HorizontalAlign="center" Visible="false"/>
<asp:TemplateField headertext="Answer">
<ItemTemplate>
<asp:RadioButtonList runat="server" id="rb1Answer" RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:listitem Text="Yes" value="Yes" />
<asp:listitem Text="No" value="No" />
<asp:listitem Text="N/A" value="N/A" />
</asp:RadioButtonList><br />
<asp:textbox id="txtComments" runat="server" textmode="multiline" height="40" width="600" OnKeyPress="max_Length(event, this, 200)" />
<asp:radiobuttonlist id="rblOptions" runat="server" RepeatLayout="Flow" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
after answering the questions, the options that i selected along with my comments must be displayed in the grid.
but now the question column only getting filled. But data saved properly and retrieved.
code behind...
string sql = " select b.Descritpion category, id Qid,ROW_NUMBER() OVER (ORDER BY id) AS QNo, A.Question,C.risk_rating,C.answer,C.comment " + " from AppraisalQuestions A inner Join Questioncategory B On A.Question_Number =b.Categorycode and a.Form='AU'and isActive = 1 and " + category +
" left outer join appraisalanswers c on a.id= c.question_id and audit_id = @id order by id";
bindGridView(sql, gvName, _params);
protected virtual void bindGridView(string sql, GridView gv, List<SqlParameter> pars = null, String db = "SSS", CommandType type = CommandType.Text)
{
if (gv.AllowPaging)
{
gv.DataSource = DAL.executeDataTable(sql, pars, type, db);
gv.DataBind();
}
else
{
gv.DataSource = type == CommandType.Text ? DAL.executeQuery(sql, pars, db) : DAL.executeStoredProcedureQuery(sql, pars, db);
gv.DataBind();
}
}
please correct me...