+ Reply to Thread
Page 5 of 6 FirstFirst ... 3 4 5 6 LastLast
Results 41 to 50 of 54

Thread: Create control according to their data type

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

    hey J

    I m using repeater and so far i converted code here.see the bold part .i m not using list view .
    this line Listview1.DataKeys(lvi.DisplayIndex).Value is for list view i want this line converted for repeater.
    Code:
    public void AddRowstoIDList()
        {
            // Loop through all the current items in the Listview
            foreach (RepeaterItem item in rptExtraInfo.Items) 
            {
                
                CheckBox chkbox = (CheckBox)item.FindControl("chkBox");
               
                if ((((chkbox) != null))) 
                {
                        int ID = Convert.ToInt32(rptExtraInfo.Items[item.ItemIndex].ItemIndex); 
                        if ((chkbox.Checked && !this.IDs.Contains(ID)))
                        { 
                            // Add the ID to our list 
                            this.IDs.Add(ID); 
                        } 
                        else if ((!chkbox.Checked && this.IDs.Contains(ID))) { 
                            // Not checked - remove the ID from our list 
                            this.IDs.Remove(ID); 
                        } 
    
                        
                }
                
            }
    
    Love is physical attraction and mental destruction

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

    this line is not working.
    Code:
    int ID = Convert.ToInt32(rptExtraInfo.Items[item.ItemIndex].ItemIndex);
    
    so can anyone tell me how to get id of check box in repeater.
    Love is physical attraction and mental destruction

  3. #43
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,533
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    You need to use the FindControl method. You can call this within the ItemCommand event or the ItemDataBound event, for example. It just depends on what you're trying to do.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


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

    hi
    even my check box is checked but this always return false
    Code:
      CheckBox chkbox = (CheckBox)item.FindControl("chkBox");
    if (chkbox.Checked)
    
    why??
    Love is physical attraction and mental destruction

  5. #45
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,533
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    Quote Originally Posted by guddu View Post
    hi
    even my check box is checked but this always return false
    Code:
      CheckBox chkbox = (CheckBox)item.FindControl("chkBox");
    if (chkbox.Checked)
    
    why??
    False is the default value...I'm guessing that the checkbox hasn't yet been set in the repeater. What event is this code running in?
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


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

    ok now check box issue is resolved.now i m able to maintain the state of check box.but how to maintain state of text box.The link u have given about check box is using list to maintain id.

    but for text box i want to maintain id and corrsponding value .how to do this?
    Love is physical attraction and mental destruction

  7. #47
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,533
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    It's the same concept as the checkbox, but you need to store the additional value.

    The checkbox example only stores the ID's of checkboxes that are checked. So you'll only want to store the ID's of textboxes that actually have text. You could store a DataTable in viewstate instead of a List. This would allow you to have two columns (id and value).
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


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

    hi actually now i m using Hash table to store key and value.below code in repeater creates text boxes.in asp what we do give unqiue name to each text boxes when we create no of text boxes from database.so that we uniquelly identify them.but in .net how to identify the, uniquelly.
    Code:
    <asp:TextBox runat="server" Visible='<%#VisibleTextBoxYesNo(DataBinder.Eval(Container .DataItem,
                                        "DataTypeN0").ToString())%>' ID='txtBox'></asp:TextBox>
    
    hope it make some sense.
    Love is physical attraction and mental destruction

  9. #49
    The Barnfather jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead has much to be proud of jmurrayhead's Avatar
    Join Date
    Mar 2008
    Location
    Reston, VA
    Posts
    4,533
    Blog Entries
    9
    Real Name
    Jason
    Rep Power
    22

    The controls in the repeater are automatically assigned a unique ID.
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


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

    i want to access that ids in one of my method.how can we access.these controls are in repeater.i want to access them in below method not in ItemCommand event or the ItemDataBound event.
    public void AddRowstoIDList()
    {
    }
    Love is physical attraction and mental destruction

+ Reply to Thread
Page 5 of 6 FirstFirst ... 3 4 5 6 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