DeveloperBarn Forums

DeveloperBarn

Programming & IT forum

Create control according to their data type

This is a discussion on Create control according to their data type within the .Net Development forums, part of the Programming & Scripting category; First you will have to iterate throught the Repeater's Items collection using a For loop...During this iteration, you'll have to ...

Go Back   DeveloperBarn Forums > Programming & Scripting > .Net Development

  #51  
Old January 23rd, 2009, 10:43 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,964
Blog Entries: 8
Rep Power: 15
jmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud ofjmurrayhead has much to be proud of
Default

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 with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

If you like it here...throw us a few bones to help
support us.

Join our Folding team: DeveloperBarn Folding

Reply With Quote
  #52  
Old January 23rd, 2009, 11:00 AM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default

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
Reply With Quote
  #53  
Old January 23rd, 2009, 11:10 AM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default

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.
Reply With Quote
  #54  
Old January 23rd, 2009, 12:21 PM
guddu's Avatar
Barn Enthusiast
 
Join Date: Jul 2008
Location: Oxford UK
Posts: 334
Rep Power: 2
guddu is on a distinguished road
Default

@J
any idea .i m now fully blank.i think ASP is better than asp.net.
Reply With Quote
Reply

  DeveloperBarn Forums > Programming & Scripting > .Net Development

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads

Thread Thread Starter Forum Replies Last Post
Create/Print Form data Rebelle ASP Development 5 December 10th, 2008 10:25 AM
Binding data to the RadioButtonList Control Shem .Net Development 2 December 3rd, 2008 02:42 AM
The data source 'ObjectDataSource1' does not support sorting with IEnumerable data Shem .Net Development 5 June 25th, 2008 08:07 AM
Data Type Mismatch in Criteria Expression alansidman Microsoft Access 1 April 9th, 2008 04:33 PM
[Error] Type mismatch: HTMLEncode Rebelle ASP Development 20 March 28th, 2008 09:30 AM


All times are GMT -4. The time now is 11:24 PM.


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2