I have a GridView below that will show some text and provide a checkbox.
<asp:GridView ID="surveyTableTest" runat="server" AutoGenerateColumns="false" >
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hdnSurveyID" runat="server" Value='<%#DataBinder.Eval(Container.DataItem, "survey_id") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="URL">
<ItemTemplate>
<asp:Label ID="surveyURL" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "URL") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Used">
<ItemTemplate>
<asp:CheckBox ID="surveyUsed" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I have a simple class which is bound to the GridView. This is populated from a SQL stored procedure.
public class surveyURL
{
public int survey_id { get; set; }
public string URL { get; set; }
public string used { get; set; }
}
How can I take the information from 'used' which is NCHAR(1) 'Y' or 'N' and turn that into a checkbox.checked result where 'used' = 'Y'
This is what I am currently doing in C#, this is enough to populate the hiddenfield and first template field. I don't know how to proceed for the checkbox.
var test = cn.Query<surveyURL>("sp_create_url", p, commandType: CommandType.StoredProcedure);
surveyTableTest.DataSource = test;
surveyTableTest.DataBind();
Aucun commentaire:
Enregistrer un commentaire