hello everybody
i have xmlfile and i showen its in gridview
so how i can make ID column as hyperlink when i click any Id number its open new page and show me information in text box
this is my code
="1.0"="yes"
<Students>
<Student>
<ID>1</ID>
<Name> ahmad </Name>
<Email> Ahmad@xml.com </Email>
<Address> Amman </Address>
<Mobile> 0781178778 </Mobile>
<Class> Seventh </Class>
</Student>
<Student>
<ID>2</ID>
<Name> Khaled </Name>
<Email> Khaled@xml.com </Email>
<Address> Zarqa </Address>
<Mobile> 078232342 </Mobile>
<Class> Sixth </Class>
</Student>
</Students>
and this is the first page(its called Default) html code
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:GridView ID="GridView1" runat="server"
onselectedindexchanged="GridView1_SelectedIndexChanged" CellPadding="0"
Width="1px">
</asp:GridView>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Add New Student" Width="118px" />
</asp:Content>
and this is friest page behind code
using System.Data;
using System.Xml;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet s = new DataSet();
s.ReadXml(Server.MapPath("Courses.xml"));
GridView1.DataSource= s.Tables[0];
GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
int gridrowscount = GridView1.Rows.Count;
Response.Redirect("Default2.aspx?ID="+gridrowscount);
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
int gridrowscount = GridView1.Rows.Count;
Response.Redirect("Default2.aspx?ID=");
}
}
and this is second page (called Default2.aspx) behind code
public partial class Default2 : System.Web.UI.Page
{
int intID;
string ID;
protected void Page_Load(object sender, EventArgs e)
{
intID = int.Parse(Request.Params["ID"]) + 1;
ID = intID.ToString();
string s = Request.QueryString[0];
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
DataSet dsXML = new DataSet();
dsXML.ReadXml(Server.MapPath("~/") + "Courses.xml");
if (dsXML.Tables.Count > 0)
{
DataRow drstudent = dsXML.Tables[0].NewRow();
drstudent["ID"] = Server.HtmlEncode(ID);
drstudent["Name"] = Server.HtmlEncode(TextBox1.Text);
drstudent["Email"] = Server.HtmlEncode(TextBox2.Text);
drstudent["Address"] = Server.HtmlEncode(TextBox3.Text);
drstudent["Mobile"] = Server.HtmlEncode(TextBox4.Text);
drstudent["Class"] = Server.HtmlEncode(TextBox5.Text);
dsXML.Tables[0].Rows.Add(drstudent);
}
dsXML.WriteXml(Server.MapPath("~/") + "Courses.xml");
Response.Redirect("default.aspx");
}
private void BindData()
{
XmlTextReader xmlReader = new XmlTextReader(Server.MapPath("Courses.xml"));
xmlReader.Close();
}
}