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; hey J I m using repeater and so far i converted code here.see the bold part .i m not using ...

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

  #41  
Old January 22nd, 2009, 10:34 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

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
Reply With Quote
  #42  
Old January 22nd, 2009, 04:18 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

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.
Reply With Quote
  #43  
Old January 22nd, 2009, 04:40 PM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,962
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

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 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
  #44  
Old January 22nd, 2009, 06:35 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

hi
even my check box is checked but this always return false
Code:
  CheckBox chkbox = (CheckBox)item.FindControl("chkBox");
if (chkbox.Checked)
why??
Reply With Quote
  #45  
Old January 23rd, 2009, 08:40 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,962
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

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?
Reply With Quote
  #46  
Old January 23rd, 2009, 09:28 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 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?
Reply With Quote
  #47  
Old January 23rd, 2009, 09:57 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,962
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

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).
Reply With Quote
  #48  
Old January 23rd, 2009, 10:24 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

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.
Reply With Quote
  #49  
Old January 23rd, 2009, 10:33 AM
jmurrayhead's Avatar
The Barnfather
 
Join Date: Mar 2008
Real name: Jason
Location: Washington, D.C.
Posts: 1,962
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

The controls in the repeater are automatically assigned a unique ID.
Reply With Quote
  #50  
Old January 23rd, 2009, 10:38 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 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()
{
}
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 07:06 AM.


Copyright ©2008-2010, DeveloperBarn

Content Relevant URLs by vBSEO 3.3.2