|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:
//I query the db in pageload() event:
//We query the DB only once in the Page Load
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();
//Then I call it in ItemDataBound...) event
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
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.