AutoCompleteExtender and Dynamically created Row

I am adding a new row to gv in javascript.

Page 1 of 1

1 Replies - 4381 Views - Last Post: 25 October 2009 - 02:03 PM Rate Topic: -----

#1 mtndrmr  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 25-October 09

AutoCompleteExtender and Dynamically created Row

Posted 25 October 2009 - 11:43 AM

function testww(xx)
{

var tbl=document.getElementById('gv');
var rowElements = document.getElementById('gv').getElementsByTagName('tr');
		 var lastRow = rowElements.length;
		 var iteration = lastRow;		 
		var row=tbl.insertRow(3);
		 
		 var newCell = row.insertCell(0);
		 var textNode=document.createTextNode(iteration);
		 newCell.appendChild(textNode);
		 
		 var newCell2 = row.insertCell(1);
		 var newTextBox = document.createElement('input');
			 newTextBox.type='text';
			 newTextBox.name='txtRow'+iteration;				newTextBox.id=newIDText+'DropDownList1';
			 newTextBox.size=40;
			 newTextBox.setAttribute('onclick','greeting()');
			 newCell2.appendChild(newTextBox);
			 //alert("the row is added");
			 
		  
		 var newCell3 = row.insertCell(2);
		 var newTextBox = document.createElement('input');
			 newTextBox.type='text';
			 newTextBox.name='txtRow'+iteration;
			 newTextBox.id='txtRow'+iteration;
			 a=newTextBox.id
			 newTextBox.size=40;
			 newTextBox.value="Hello this is a new row";
			 newCell3.appendChild(newTextBox);
			 //alert("the row is added
			var rowAddedID = iteration;
		  
			var yy=document.getElementById('txtRow'+iteration-2);
			 //-----clone a row
			//var newNode = rowElements[1].cloneNode(true);//row to clone
			//row.appendChild(newNode);//appending
			//alert('New Row Length is: '+lastRow);
			//loop through table rows
			
		  if (lastRow > 0)
		  {
				for (var i = 0; i < 10; i++)
				 {
				var row = rowElements[i];
			  var fields = rowElements[i].getElementsByTagName('input');
				//loop through cells in rows
				 for(var z = 0; z<fields.length; z++) 
				{
				var indField = fields[z];
				var fldName=indField.id;
				var fldVal = indField.value;
				 Sys$UI$AutoCompletebehavior$_init(fldName);
				}
				}
			}
					   
}

aspx 
<asp:GridView ID="gv" runat="server" AutoGenerateColumns="False" DataKeyNames="appl_id"
			DataSourceID="SqlDataSource1">
			<Columns>
				<asp:TemplateField HeaderText="appl_id" InsertVisible="False" SortExpression="appl_id">
					 <ItemTemplate>
						<asp:TextBox ID="Label1" runat="server" Text='<%# Bind("appl_id") %>'></asp:TextBox>
					</ItemTemplate>
				</asp:TemplateField>
				
				<asp:TemplateField HeaderText="prog_id" SortExpression="prog_id">
					<ItemTemplate>
						<asp:TextBox ID="Label2" runat="server" Text='<%# Bind("prog_id") %>'></asp:TextBox>
					</ItemTemplate>
				</asp:TemplateField>
				
				<asp:TemplateField HeaderText="appl_date" SortExpression="appl_date">
					 <ItemTemplate>
						<asp:TextBox ID="Label3" runat="server" Text='<%# Bind("appl_date") %>' onclick="testxx()"></asp:TextBox>
					</ItemTemplate>
				</asp:TemplateField>
				<asp:TemplateField HeaderText="InsertRow" SortExpression="appl_date">
					 <ItemTemplate>
						<asp:TextBox ID="Label6" runat="server" Text="clone" onclick="insRow()"></asp:TextBox>
					</ItemTemplate>
				</asp:TemplateField>
				<asp:TemplateField HeaderText="appl_type" SortExpression="appl_type">
					 <ItemTemplate>
						<asp:TextBox ID="Label4" runat="server" Text='<%# Bind("appl_type") %>' onclick="testww(this)"></asp:TextBox>
					</ItemTemplate>
				</asp:TemplateField>
				<asp:TemplateField HeaderText="ddl">
					<ItemTemplate>
						<asp:TextBox ID="DropDownList1" runat="server">
						</asp:TextBox>
							 <cc1:AutoCompleteExtender											  
				  runat="server" 
				  Enabled="true"						  
				  ID="autoComplete1"												
				  TargetControlID="DropDownList1"   
				  ServicePath="../AutoComplete.asmx"	 
				  ServiceMethod="GetCompletionList"											
				  MinimumPrefixLength="1"											
				  CompletionInterval="100"											
				  EnableCaching="true"											 
				  CompletionSetCount="25"
				  CompletionListCssClass = "completionList"
				  CompletionListHighlightedItemCssClass ="itemHighlighted"
				  CompletionListItemCssClass = "listitem">
			 </cc1:AutoCompleteExtender>
					</ItemTemplate>
				</asp:TemplateField>
			  
			</Columns>
		</asp:GridView>



I am adding a new row to the gridview clientside. How do I get the new textbox in the new row to use the autocomplete extender?

Is This A Good Question/Topic? 0
  • +

Replies To: AutoCompleteExtender and Dynamically created Row

#2 markhazlett9  Icon User is offline

  • Coding is a lifestyle
  • member icon

Reputation: 60
  • View blog
  • Posts: 1,666
  • Joined: 12-July 08

Re: AutoCompleteExtender and Dynamically created Row

Posted 25 October 2009 - 02:03 PM

This should be in the asp.NET forum.. I'll get one of the mods to move it

Cheers

Ps. for future reference please use the code tags properly
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1