|
-
Mar 12th, 2010, 01:43 PM
#1
Thread Starter
Hyperactive Member
-
Mar 12th, 2010, 02:41 PM
#2
Frenzied Member
Re: Grd Small Problem
Scratch that. Eh this forum needs a delete.
Sean
Some days when I think about the next 30 years or so of my life I am going to spend writing code, I happily contemplate stepping off a curb in front of a fast moving bus.
-
Mar 12th, 2010, 02:55 PM
#3
Hyperactive Member
Re: Grd Small Problem
I find it hard to understand. Can you repost the question in simple English?
-
Mar 13th, 2010, 03:24 AM
#4
Hyperactive Member
Re: Grd Small Problem
how did u bind..i mean show me the code behind..@
-
Mar 13th, 2010, 04:30 AM
#5
Re: Grd Small Problem
Hey Sean,
PowerPosters can delete their own posts, and Moderators can delete anyone's posts. If you hit the red triangle in your post, and write a note explaining you would like the post deleted, a Moderator will come along and delete it for you.
Gary
-
Mar 13th, 2010, 04:34 AM
#6
Re: Grd Small Problem
Sonia,
There must be more code than what you have shown. Can you provide more details.
More instance, are you using an XmlDataSource to link the GridView to the xml file, or how are you connecting the two.
Gary
-
Mar 13th, 2010, 10:12 AM
#7
Thread Starter
Hyperactive Member
Re: Grd Small Problem
Code:
if (!IsPostBack)
{
if (!IsPostBack)
{
ds = new DataSet();
ds.ReadXml("C:\\Users\\indel_intern96\\Desktop\\SONIA FOLDER\\sonia1.xml");
GridView1 .DataSource = ds;
GridView1.DataBind();
}
}
So sad,my thread is too bad,dat people want it to delete!!!
-
Mar 13th, 2010, 10:22 AM
#8
Re: Grd Small Problem
 Originally Posted by sonia.sardana
So sad,my thread is too bad,dat people want it to delete!!!
No, this isn't the case, Sean was talking about his post within your thread. He started typing something and then changed his mind, but isn't able to delete his post.
Gary
-
Mar 13th, 2010, 10:34 AM
#9
Re: Grd Small Problem
Hey,
Because of the way that you are loading the XML, you don't have an "easy" way of re-ordering the columns. However, one way to do this would be the following:
Code:
if (!IsPostBack)
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("XMLFile1.xml"));
DataTable dt = ds.Tables[0];
dt.Columns["id"].SetOrdinal(0);
dt.Columns["author"].SetOrdinal(1);
dt.Columns["price"].SetOrdinal(2);
GridView1.DataSource = ds;
GridView1.DataBind();
}
Hope that helps!!
Gary
-
Mar 13th, 2010, 11:01 AM
#10
Hyperactive Member
Re: Grd Small Problem
gud one ...working great..
-
Mar 14th, 2010, 02:46 AM
#11
Thread Starter
Hyperactive Member
Re: Grd Small Problem
Thx gep sir very Much.
Means If the XML file is in order
id author price,its not necessary dat in dataset - columns are also in order id author price.Rite na??
-
Mar 14th, 2010, 05:56 AM
#12
Re: Grd Small Problem
Hey,
Yes. I don't know exactly how the DataSet.ReadXml orders the column, like you, I would have assumed the order in which they are defined in the XML, but that is clearly not the case. I suspect it is something to do with the fact that ID is actually an attribute on the book node, rather than a contained child node, like the other two, but that is a complete guess.
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|