+ Reply to Thread
Page 2 of 6 FirstFirst 1 2 3 4 ... LastLast
Results 11 to 20 of 54

Thread: Create control according to their data type

  1. #11
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    I would use a direct SQL data reader...

    Only thing to remember with a repeater is the control itself doesn't render anything. So, unlike a gridview (I think) it won't put a <table> tag or <tr><td> tags for each row. All it does is render the details inside the various templates (Item, Alternating etc.) for each record in the datasource.

    Hope that helps.

  2. #12
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    471
    Rep Power
    4

    last doubt how to use repeater control with business and data layer.
    any sample code u refer?
    Love is physical attraction and mental destruction

  3. #13
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    You just set the datasource of the repeater to the function that returns the data from the database.
    Code:
    sub Page_Load()
     
    If Not IsPostback then
        repeater1.Datasource = BLL.GetData()
        repeater1.Databind()
    End If
     
    End Sub
    
    Code:
    <asp:repeater id="repeater1" runat="server" OnItemDataBind="repeater1_OnItemDataBind">
    .
    .
    </asp:repeater>
    
    Code:
    Sub repeater1_OnItemDataBind(ByVal s As Object, ByVal e As RepeaterItemEventArgs)
    If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItem.AlternatingItem then
      Dim objBOL As BOLObject = e.Item.DataItem
      If objBOL.your_property = "whatever" then
           'do this
      End if
    End If
    End Sub
    
    Hope that helps.

  4. #14
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    471
    Rep Power
    4

    hi
    i want to give unique id to my text box .i m getting server tag not well formed tag?
    Code:
    <asp:TableCell runat="server" Width="10%">
                                        <asp:TextBox runat="server" ID="txtBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>"></asp:TextBox>
                                        <asp:ListBox runat="server" ID="lstBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>"></asp:ListBox>
                                    </asp:TableCell>
    
    Love is physical attraction and mental destruction

  5. #15
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    Try changing the " to '
    Code:
    <asp:TableCell runat="server" Width="10%">
                                        <asp:TextBox runat="server" ID='txtBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>'></asp:TextBox>
                                        <asp:ListBox runat="server" ID='lstBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>'></asp:ListBox>
                                    </asp:TableCell>
    

  6. #16
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    471
    Rep Power
    4

    now getting below error
    Error1 'txtBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>'
    is not a valid identifier.
    Love is physical attraction and mental destruction

  7. #17
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    471
    Rep Power
    4

    hi
    and with above i m looking for this also.
    Code:
    <ItemTemplate>                        
                            <asp:Table runat="server" Width="60%" HorizontalAlign="Center">
                                <asp:TableRow runat="server">
                                    <asp:TableCell runat="server" Width="10%">
                                        <%# DataBinder.Eval(Container.DataItem, "Description")%>
                                    </asp:TableCell>
                                    <asp:TableCell runat="server" Width="10%">
                                        <%# DataBinder.Eval(Container.DataItem, "DataType")%>
                                        +
                                        <%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>
                                    </asp:TableCell>
                                    <asp:TableCell runat="server" Width="10%">
                                        <asp:TextBox runat="server" ID='txtBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>'></asp:TextBox>
                                        <asp:ListBox runat="server" ID='lstBox<%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%>'></asp:ListBox>
                                    </asp:TableCell>
                                </asp:TableRow>
                            </asp:Table>                             
                        </ItemTemplate>
    
    if <%# DataBinder.Eval(Container.DataItem, "DataTypeN0")%> value of this 4 then it will display only text box and if value is 5 then will display only select box.how to check such a condition here??
    Love is physical attraction and mental destruction

  8. #18
    Administrator richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich is a splendid one to behold richyrich's Avatar
    Join Date
    Mar 2008
    Location
    Somewhere only we know...
    Posts
    3,207
    Blog Entries
    14
    Real Name
    Rich
    Rep Power
    14

    .NET assigns unique IDs to controls automatically. Is there any reason you want to change them to something else?

    If you want to make changes to the IDs of controls etc. and also for checking values of items and changing the details displayed accordingly, use the OnItemDataBound method of your repeating control.

    Then, for each item it binds, you can retrieve the controls and values and make any alterations before the code is rendered.

    Hope that helps.

  9. #19
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    471
    Rep Power
    4

    hi Thanks for a reply.i skipped the idea of assigning id.and for display purpose i m doing like this and i think i m fine with this
    Code:
    <asp:TextBox runat="server" Visible='<%#VisibleTextBoxYesNo(DataBinder.Eval(Container .DataItem,
                                        "DataTypeN0").ToString())%>' ID='txtBox'></asp:TextBox>
    
    protected bool VisibleTextBoxYesNo(string val)
            {
                if (val == "1" || val == "2" || val == "3")
                    return (true);
    
                return (false);
            }
    
    Love is physical attraction and mental destruction

  10. #20
    Barn Enthusiast guddu is on a distinguished road guddu's Avatar
    Join Date
    Jul 2008
    Location
    Oxford UK
    Posts
    471
    Rep Power
    4

    now i m facing problem with paging in repeater.i m using datasource to make paging work but i m getting below error at bind line.

    Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index

    Code:
    PackageList dd = PackageListBL.GetExtraInfo(121);
    
    if (dd != null)
    {
    
        PagedDataSource objPds = new  PagedDataSource();
        objPds.DataSource = dd;
        objPds.AllowPaging = true;
        objPds.PageSize = 5;
        objPds.CurrentPageIndex = CurrentPage - 1;
        rptExtraInfo.DataSource = objPds;
        rptExtraInfo.DataBind();
    }
    
    Love is physical attraction and mental destruction

+ Reply to Thread
Page 2 of 6 FirstFirst 1 2 3 4 ... LastLast

Similar Threads

  1. Create/Print Form data
    By Rebelle in forum ASP Development
    Replies: 5
    Last Post: December 10th, 2008, 10:25 AM
  2. Binding data to the RadioButtonList Control
    By Shem in forum .NET Development
    Replies: 2
    Last Post: December 3rd, 2008, 02:42 AM
  3. Replies: 5
    Last Post: June 25th, 2008, 09:07 AM
  4. Data Type Mismatch in Criteria Expression
    By alansidman in forum Microsoft Access
    Replies: 1
    Last Post: April 9th, 2008, 05:33 PM
  5. Type mismatch: HTMLEncode
    By Rebelle in forum ASP Development
    Replies: 20
    Last Post: March 28th, 2008, 10:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO