For first row Xml data in binding to the dropdownlist ,when i add the another row to the list view .xml data is cleared in fisrt row and no data showing from second row onwards.
protected void BindDataToGridviewDropdownlist()
{
DataSet dsDept = new DataSet
dsDept.ReadXml(Server.MapPath("XMLFile2.xml"));
foreach (var list in listview1.Items)
{
if (list.ItemType == ListViewItemType.DataItem)
{
DropDownList ddf = (DropDownList)list.FindControl("ddldatatype");
ddf.DataSource = dsDept;
ddf.DataTextField = "value";
ddf.DataBind();
}
}
Plz suggest me what is the problem with this code
<asp:ListView ID="listview1" runat="server">
<LayoutTemplate>
<table border="0px" cellpadding="1">
<tr style="background-color: #E5E5FE">
<th>
Order
</th>
<th>
Column Title
</th>
<th>
DataType
</th>
<th>
Exapmles
</th>
<th>
Options
</th>
<th>
Delete
</th>
</tr>
<tr id="itemplaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<td>
<asp:Label ID="txtorder" Text='<%#Eval("Order") %>' runat="server"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtcolumnname" Text='<%#Eval("Columnname") %>' runat="server" Width="150"></asp:TextBox>
</td>
<td>
<asp:DropDownList ID="ddldatatype" runat="server" Width="160" >
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="ddlexamples" runat="server" Width="160">
<asp:ListItem Text="test" Value="2"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="txtoptions" Text='<%#Eval("Options") %>' runat="server" Width="150" ></asp:TextBox>
</td>
<td>
<asp:CheckBox ID="chkdel" runat="server" />
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color: #EFEFEF">
<td>
<asp:Label ID="txtorder" Text='<%#Eval("Order") %>' runat="server"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtcolumnname" Text='<%#Eval("Columnname") %>' runat="server" Width="150"></asp:TextBox>
</td>
<td>
<asp:DropDownList ID="ddldatatype" runat="server" Width="160" >
</asp:DropDownList>
</td>
<td>
<asp:DropDownList ID="ddlexamples" runat="server" Width="160">
<asp:ListItem Text="test" Value="2"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:TextBox ID="txtoptions" Text='<%#Eval("Options") %>' runat="server" Width="150"></asp:TextBox>
</td>
<td>
<asp:CheckBox ID="chkdel" runat="server" />
</td>
</tr>
XMl
<DataTypes>
<DataType value="Name">
<DataItems>
<MaleName>MaleName(John)</MaleName>
<FemaleName>FemaleName(Shermilla)</FemaleName>
<AnyGender>AnyGender</AnyGender>
</DataItems>
</DataType>
<DataType value="Email">
<DataItem>
<Not>Does not exists</Not>
</DataItem>
</DataType>
<DataType value="Phone">
<DataItem>
<A>India</A>
<B>Canada</B>
<C>Australia</C>
</DataItem>
</DataType>
<DataType value="Date">
<DataItems>
<Hh>Date Format</Hh>
</DataItems>
</DataType>
<DataType value="Company">
<DataItem>
<Aa>Does not exists</Aa>
</DataItem>
</DataType>
<DataType value="City">
<DataItem>
<Bb>No examples available</Bb>
</DataItem>
</DataType>
<DataType value="Postal">
<DataItem>
<Cc>No examples availabe</Cc>
</DataItem>
</DataType>
<DataType value="Country">
<DataItem>
<Gg>No examples available.</Gg>
</DataItem>
</DataType>
<DataType value="Latitude/Longitude">
<DataItem>
<Ff>
No examples available.
</Ff>
</DataItem>
</DataType>
<DataType value="Street Address">
<DataItem>
<Ee> No examples available.</Ee>
</DataItem>
</DataType>
<DataType value="Region">
<DataItem>
<Dd>No examples available.</Dd>
</DataItem>
</DataType>
<DataType value="Fixed Number of Words"></DataType>
<DataType value="Random Number of Words"></DataType>
<DataType value="Alpha Numeric"></DataType>
<DataType value="Auto Increment"></DataType>
<DataType value="Number Range"></DataType>
<DataType value="GUID"></DataType>
<DataType value="Currency"></DataType>
<DataType value="Constant"></DataType>
<DataType value="Composite"></DataType>
<DataType value="Custom List"></DataType>
</DataTypes>