+ Reply to Thread
Page 6 of 6 FirstFirst ... 4 5 6
Results 51 to 54 of 54

Thread: Create control according to their data type

  1. #51
    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

    First you will have to iterate throught the Repeater's Items collection using a For loop...During this iteration, you'll have to check the ItemType to ensure that you're currently in the ItemTemplate or AlternatingItemTemplate (not HeaderTemplate or FooterTemplate). Finally, you'll use FindControl and reference the control by the ID (txtBox).
    jmurrayhead
    If you agree, give me rep.
    If you like it here...throw us a few bones to help support us.


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

    ok meant i m doing in the same way u said.now i m facing very weired problem.
    see adding in list and hash table i m using below code
    Code:
    for (int i = 0; i < rptExtraInfo.Items.Count; i++) 
            {
    
                        CheckBox chkbox = (CheckBox)rptExtraInfo.Items[i].FindControl("chkBox");
                        TextBox txtbox = (TextBox)rptExtraInfo.Items[i].FindControl("txtBox");
                        
                        int ID = Convert.ToInt32(rptExtraInfo.Items[i].ItemIndex);
                            
                        if (txtbox.Text != "" && !HashTableSample.table.Contains(ID))
                        {
                            HashTableSample.AddEntry(rptExtraInfo.Items[i].ItemIndex.ToString(), txtbox.Text);
                        }
                        else if (txtbox.Text == "" && HashTableSample.table.Contains(ID))
                        {
                            HashTableSample.table.Remove(ID);
                        }
    
                        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); 
                        }       
    
                
           }
    
    for maintaining state i m pulling data from list or hash table and assigning back to text boxes and check boxes.so that during page navigation data will not lost which is entered by me.
    Code:
    protected void rptExtraInfo_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
              
                RepeaterItem lvi = e.Item;
                TextBox txtbox = (TextBox)lvi.FindControl("txtBox");
                if ((((txtbox) != null)))
                {
                   
                    int ID = Convert.ToInt32(lvi.ItemIndex);
                   
                    txtbox.Text = HashTableSample.FindEntry(lvi.ItemIndex).ToString();
                }
    
                // Find the checkbox in the current row 
                CheckBox chkSelect = (CheckBox)lvi.FindControl("chkBox");
                // Make sure we're referencing the correct control 
                if ((((chkSelect) != null)))
                {
                    // If the ID exists in our list then check the checkbox 
                    int ID = Convert.ToInt32(lvi.ItemIndex);
                    chkSelect.Checked = this.IDs.Contains(ID);
                } 
          
    
             
        }
    
    now problem is the data which i entered at first page also displaying in 2 page ,3rd page so on.so i m missing something.bcoz at each page i will enter different data.i dont understand why data of first page displaying all other pages.

    Hope it make some sense.
    Love is physical attraction and mental destruction

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

    i think problem is i m using paging in repeater.so at each page control index start from 0.so if i enter data for the control which has index 0 at first page.and i m adding this data and index 0 to my list.so when i go at 2 nd page it finds again a control of 0 index and assign the first page values to here.

    how to avoid so that control at each page behave differently.
    Love is physical attraction and mental destruction

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

    @J
    any idea .i m now fully blank.i think ASP is better than asp.net.
    Love is physical attraction and mental destruction

+ Reply to Thread
Page 6 of 6 FirstFirst ... 4 5 6

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