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 ...
| |||||||
|
#51
| ||||
| ||||
| 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 |
|
#52
| ||||
| ||||
| 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);
}
}
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);
}
}
Hope it make some sense.
__________________ Love is physical attraction and mental destruction |
|
#53
| ||||
| ||||
| 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. |
|
#54
| ||||
| ||||
| @J any idea .i m now fully blank.i think ASP is better than asp.net. |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| 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 |