Click here to Skip to main content
16,007,932 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex25-Sep-17 4:20
samflex25-Sep-17 4:20 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming25-Sep-17 4:30
mveRichard Deeming25-Sep-17 4:30 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex25-Sep-17 6:32
samflex25-Sep-17 6:32 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming25-Sep-17 6:36
mveRichard Deeming25-Sep-17 6:36 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex25-Sep-17 8:23
samflex25-Sep-17 8:23 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming25-Sep-17 10:43
mveRichard Deeming25-Sep-17 10:43 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex25-Sep-17 10:58
samflex25-Sep-17 10:58 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
samflex26-Sep-17 6:56
samflex26-Sep-17 6:56 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming26-Sep-17 7:21
mveRichard Deeming26-Sep-17 7:21 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? (SOLVED) Pin
samflex26-Sep-17 7:59
samflex26-Sep-17 7:59 
GeneralRe: Repeater2 is not getting populated with data from Repeater2. Any ideas? Pin
Richard Deeming26-Sep-17 8:05
mveRichard Deeming26-Sep-17 8:05 
QuestionMy service move my file Location but doesn't upload the data in sql server... here is my code Pin
Member 1286345320-Sep-17 1:26
professionalMember 1286345320-Sep-17 1:26 
AnswerRe: My service move my file Location but doesn't upload the data in sql server... here is my code Pin
Nathan Minier20-Sep-17 1:43
professionalNathan Minier20-Sep-17 1:43 
GeneralRe: My service move my file Location but doesn't upload the data in sql server... here is my code Pin
Member 1286345320-Sep-17 18:58
professionalMember 1286345320-Sep-17 18:58 
GeneralRe: My service move my file Location but doesn't upload the data in sql server... here is my code Pin
Nathan Minier21-Sep-17 1:43
professionalNathan Minier21-Sep-17 1:43 
GeneralRe: My service move my file Location but doesn't upload the data in sql server... here is my code Pin
Member 1286345322-Sep-17 23:44
professionalMember 1286345322-Sep-17 23:44 
AnswerRe: My service move my file Location but doesn't upload the data in sql server... here is my code Pin
Richard MacCutchan20-Sep-17 21:38
mveRichard MacCutchan20-Sep-17 21:38 
GeneralRe: My service move my file Location but doesn't upload the data in sql server... here is my code Pin
Member 1286345320-Sep-17 21:52
professionalMember 1286345320-Sep-17 21:52 
GeneralRe: My service move my file Location but doesn't upload the data in sql server... here is my code Pin
Richard MacCutchan20-Sep-17 22:16
mveRichard MacCutchan20-Sep-17 22:16 
GeneralRe: My service move my file Location but doesn't upload the data in sql server... here is my code Pin
Member 1286345320-Sep-17 22:33
professionalMember 1286345320-Sep-17 22:33 
GeneralRe: My service move my file Location but doesn't upload the data in sql server... here is my code Pin
Richard MacCutchan20-Sep-17 22:53
mveRichard MacCutchan20-Sep-17 22:53 
GeneralRe: My service move my file Location but doesn't upload the data in sql server... here is my code Pin
Member 1286345320-Sep-17 22:56
professionalMember 1286345320-Sep-17 22:56 
GeneralRe: My service move my file Location but doesn't upload the data in sql server... here is my code Pin
Member 1286345322-Sep-17 23:46
professionalMember 1286345322-Sep-17 23:46 
QuestionUnable to cast object of type 'System.DBNull' to type 'System.String'. Pin
samflex19-Sep-17 5:35
samflex19-Sep-17 5:35 
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 Smile | :)

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>
</asp:DropDownList>


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";
       // Response.Write(sSQL);
       //Response.End();
       SqlCommand cmd3 = new SqlCommand(sSQL, con);
       con.Open();
       cstable = new DataTable();
cstable.Load(cmd3.ExecuteReader());
  
  //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";
        ddlPState.DataBind();


Any ideas how to resolve this?

Thanks as always
AnswerRe: Unable to cast object of type 'System.DBNull' to type 'System.String'. Pin
Richard Deeming19-Sep-17 6:04
mveRichard Deeming19-Sep-17 6:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.