|I have this RadioButtonList in Repeater control.
We are using Repeater control dynamically add new rows. I seem to handle projects where rows are dynamically added
In any case, when a record is added for the first time for just one row, there are no issues with this line of code:
<asp:RadioButtonList ID="rdlmhorsepType" Text='<%#string.IsNullOrEmpty((string)Eval("rdlmhorsepType")) ? "Recoil" : Eval("rdlmhorsepType") %>' runat="server" ValidationGroup ="stype" RepeatDirection="Horizontal" TextAlign="Right" style="display:inline;">
However, when one row is filled with data and another row is added, I run into the following error messages:
able to cast object of type 'System.DBNull' to type 'System.String'.
While I am at this, is there a way to populate dynamically populated dropdownlist in Repeater?
I have this:
<asp:DropDownList ID="ddlPrevState" cssClass="disabledcss" runat="server" AppendDataBoundItems="True">
<asp:ListItem Value="" Selected="True"></asp:ListItem>
Here is C# code:
con = new SqlConnection(ConfigurationManager.ConnectionStrings["ppmtest"].ToString());
string sSQL = "Select sID,sName from states ORDER By sName ASC";
SqlCommand cmd3 = new SqlCommand(sSQL, con);
cstable = new DataTable();
protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
var ddlPState = (DropDownList)e.Item.FindControl("ddlPrevState");
ddlPState.DataSource = cstable;
ddlPState.DataTextField = "sName";
ddlPState.DataValueField = "sID";
Any ideas how to resolve this?
Thanks as always