hi everyone i am using asp.net and xml to create a page but it gives me an error
System.Web.HttpException: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'para'.
**AdminWelcomeMsg.aspx**
<%@ Page Language="C#" MasterPageFile="ContentMasterPage.master" Debug="true"%>
<%@ Import Namespace="System.Xml"%>
<%@ Import Namespace="System.Xml.Xsl" %>
<%@ Import Namespace="System.Xml.XPath" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.IO" %>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script runat="server">
void Page_load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
WelcomeData.DataSource = LoadWelcome();
WelcomeData.DataBind();
}
if (Session["error_msg"] != null)
{
ErrorMessage.Text = Session["error_msg"].ToString();
Session["error_msg"] = null;
ErrorMessage.Visible = true;
}
}
protected DataSet LoadWelcome()
{
string sourceXML = Server.MapPath("../App_Data/DefaultMsg.xml");
if ((!File.Exists(sourceXML)))
{
return null;
}
DataSet cachedDataSet = (DataSet)Session["MyWelcome"];
if (((cachedDataSet != null)))
{
return cachedDataSet;
}
DataSet dataSet = new DataSet();
try
{
dataSet.ReadXml(sourceXML);
Session["MyWelcome"] = dataSet;
}
catch (Exception e)
{
ErrorMessage.Text = e.Message;
dataSet = null;
}
return dataSet;
}
public void Welcome_Edit(object Sender, DataGridCommandEventArgs E)
{
WelcomeData.EditItemIndex = (int)E.Item.ItemIndex;
WelcomeData.DataSource = LoadWelcome();
WelcomeData.DataBind();
}
public void Welcome_Update(object Sender, DataGridCommandEventArgs E)
{
DataSet dataSet = LoadWelcome();
int row = (int)E.Item.ItemIndex;
TextBox EditText;
EditText = (TextBox)E.Item.FindControl("txtpara");
dataSet.Tables[0].Rows[row]["para"] = EditText.Text;
dataSet.WriteXml(Server.MapPath("../App_Data/DefaultMsg.xml"));
Session["MyWelcome"] = null;
WelcomeData.EditItemIndex = -1;
WelcomeData.DataSource = LoadWelcome();
WelcomeData.DataBind();
Session["error_msg"] = "The message was updated successfully";
Response.Redirect("AdminWelcomeMsg.aspx");
}
public void Welcome_Cancel(object Sender, DataGridCommandEventArgs E)
{
WelcomeData.EditItemIndex = -1;
Session["MyImage"] = null;
WelcomeData.DataSource = LoadWelcome();
WelcomeData.DataBind();
}
public void Welcome_Delete(object Sender, DataGridCommandEventArgs E)
{
DataSet dataSet = LoadWelcome();
int row = (int)E.Item.ItemIndex;
dataSet.Tables[0].Rows[row].Delete();
dataSet.WriteXml(Server.MapPath("../App_Data/DefaultMsg.xml"));
Session["MyWelcome"] = null;
WelcomeData.EditItemIndex = -1;
WelcomeData.DataSource = LoadWelcome();
WelcomeData.DataBind();
Session["error_msg"] = "The message was deleted successfully";
Response.Redirect("AdminWelcomeMsg.aspx");
}
public void Welcome_Add(object Sender, EventArgs E)
{
DataSet dataSet = LoadWelcome();
DataRow newRow;
newRow = dataSet.Tables[0].NewRow();
newRow["para"] = "";
dataSet.Tables[0].Rows.Add(newRow);
dataSet.WriteXml(Server.MapPath("../App_Data/DefaultMsg.xml"));
Session["MyWelcome"] = null;
WelcomeData.DataSource = LoadWelcome();
WelcomeData.DataBind();
WelcomeData.EditItemIndex = WelcomeData.Items.Count - 1;
WelcomeData.DataSource = LoadWelcome();
WelcomeData.DataBind();
}
</script>
<div id="content">
<div class="about">
<h2>Home Page Message</h2><hr />
On this page you can add a message to the home page, update the
existing message or delete the message.<br /><br />
<b><i><asp:Label ID="ErrorMessage" runat="server" ForeColor="Red" /></i></b><br /><br />
<asp:LinkButton ID="LinkButton5" OnClick="Welcome_Add" Text="Add a welcome message" runat="server" /><br />
<b><i><asp:Label ID="WelcomeMsg" runat="server" /></i></b><br />
<asp:DataGrid ID="WelcomeData" AutoGenerateColumns="false" Width="100%" runat="server"
OnEditCommand="Welcome_Edit" OnUpdateCommand="Welcome_Update" OnCancelCommand="Welcome_Cancel"
OnDeleteCommand="Welcome_Delete">
<HeaderStyle ForeColor="White" BackColor="Maroon" Font-Bold="true" />
<ItemStyle BackColor="White" />
<AlternatingItemStyle BackColor="AntiqueWhite" />
<Columns>
<asp:TemplateColumn HeaderText="Welcome Msg">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "para")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtpara" Size="25" Text='<%# DataBinder.Eval(Container.DataItem, "para")%>' runat="server"/>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="txtpara" Font-Italic="true"
Display="Dynamic" runat="server" ErrorMessage="(Required)" ForeColor="Red" ValidationGroup="Paras" />
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" CommandName="Edit" Text="Edit" runat="server" ValidationGroup="Paras" />
<asp:LinkButton ID="LinkButton2" CommandName="Delete" Text="Delete" runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:LinkButton ID="LinkButton3" CommandName="Cancel" Text="Cancel" runat="server"/>
<asp:LinkButton ID="LinkButton4" CommandName="Update" Text="Update" runat="server" ValidationGroup="Paras" />
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</div>
<img src="../App_Themes/theme/html/images/phone.jpg" alt="" width="953" height="87" /><br />
</div>
</asp:Content>
**DefaultMsg.xml**
<?xml version="1.0" standalone="yes"?>
<welcome>
<para>
text text text
</para>
<para>
text text text
</para>
<para>
text text text
</para>
<para>
text text text
</para>
</welcome>