How to fill in radio button with iTextSharp
asp.net, c#, itext, pdf, sql
Solution
+1 for using iText RUPS!
You should be able to do:
pdfFormFields.SetField("SEXpg2", "MALEpg2");
and
pdfFormFields.SetField("SEXpg2", "FEMALEpg2");
Problem
I have a radio group which I am trying to fill using `iTextSharp` library. When I opened the PDF in `iText RUPS` I see the following: This is how it is in the PDF file: I have the following code-behind which is supposed to populate either MALE or FEMALE radio button: ``` if (reader.GetValue(4).ToString() == "M") { pdfFormFields.SetField("SEXpg2", "Yes"); } else { pdfFormFields.SetField("SEXpg2", "Yes"); } ``` When I run the PDF form, none of the radio is populated. How can I modify the code from the screenshot so it populates either radio based on the gender column from the sql query? I tried the following but that didn't work: ``` if (reader.GetValue(4).ToString() == "M") { pdfFormFields.SetField("MALEpg2", "Yes"); } else { pdfFormFields.SetField("FEMALEpg2", "Yes"); } ```