This is a migrated thread and some comments may be shown as answers.

Help binding a usercontrol within details view

4 Answers 26 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gareth
Top achievements
Rank 1
Gareth asked on 18 Jul 2014, 04:55 PM
Hi  I have a user control that I am trying to populate within a nested Gridview  detail view,   the code below shows the casesOrdered value  but not in the user control uc1:BrandVisit  which accepts inputs as in casesMerchandised  How can I bind values to this user control?   Any ideas would be much appreciated


<asp:DetailsView ID="DetailsView1" AllowPaging="true" runat="server" GridLines="None" Width="100%" DataSourceID="
<asp:DetailsView ID="DetailsView1" AllowPaging="true" runat="server" GridLines="None" Width="100%" DataSourceID="SqlDataSourceVimto" Font-Italic="true" AutoGenerateRows="false">
               <Fields>
                   <asp:TemplateField><ItemTemplate>
                        Cases are  <%# Convert.ToDecimal(Eval("casesOrdered")) %>
                      
                          <uc1:brandVisit  runat="server" ID="brandVisit"   casesOrdered='<%# Bind("casesOrdered") %>'  OnDataBinding="brandVisit_DataBinding" casesMerchandised="12"   />
 
                   </ItemTemplate></asp:TemplateField>
               </Fields>
           </asp:DetailsView>
"
Font-Italic="true" AutoGenerateRows="false">
               <Fields>
                   <asp:TemplateField><ItemTemplate>
                        Cases are  <%# Convert.ToDecimal(Eval("casesOrdered")) %>
                      
                          <uc1:brandVisit  runat="server" ID="brandVisit"   casesOrdered='<%# Bind("casesOrdered") %>'  OnDataBinding="brandVisit_DataBinding" casesMerchandised="12"   />
 
                   </ItemTemplate></asp:TemplateField>
               </Fields>
           </asp:DetailsView>

 

The BradVisit User contro is like below
public decimal casesOrdered
  {
      get
      {
          return decimal.Parse(tbCasesOrdered.Text);
      }
      set{
          tbCasesOrdered.Text = value.ToString();
      }
    }




4 Answers, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 23 Jul 2014, 09:00 AM
Hello Gareth,

Could you please try using the Eval() instead of Bind() like is shown into the following article and let me know if the issue still exists:
http://aspsnippets.com/Articles/Bind-UserControl-inside-GridView-control-in-ASPNet.aspx

Looking forward for your reply.

Regards,
Radoslav
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Gareth
Top achievements
Rank 1
answered on 24 Jul 2014, 08:00 AM
Thanks Radoslav

Have tried both Eval() and  of Bind() neither worked.    In the end I've used DetailTables  with GridTable views instead of nestedviews
and the user control works.

Regards
Gareth
0
Accepted
Radoslav
Telerik team
answered on 25 Jul 2014, 10:40 AM
Hi Gareth,

I am sending you a simple example based on your code snippets, however everything works as expected. Please check it out and let me know what differs in your case.

Looking forward for your reply.

Regards,
Radoslav
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Gareth
Top achievements
Rank 1
answered on 25 Jul 2014, 10:48 AM
Hi Radoslav,

Thanks for sending the example,   I beleive the problem was cause because of using a nestedView Template in the RadGrid...  I rebuilt the page using GridTableViews + DetailTables  inside the RadGrid and the user control populates correctly.

Regards
Gareth
Tags
Grid
Asked by
Gareth
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Gareth
Top achievements
Rank 1
Share this question
or