|
I would use XPath or XmlDocument and then rebind the grid.
|
|
|
|
|
am sorry! how?! let me give an example
<Contact>
<Description>Mobile</Description>
<Number>111111</Number>
</Contact>
<Contact>
<Description>Office</Description>
<Number>333333</Number>
</Contact>
<Contact>
<Description>Home</Description>
<Number>222222</Number>
</Contact>
How can I move the Home to be be in the middle?
|
|
|
|
|
jrahma wrote: How can I move the Home to be be in the middle?
Either manually, or by sorting the entries. Assuming that you'd want to sort it, there's two ways of doing so. The first option would be to use XSLT[^], the second option would be using the XmlDocument class to sort[^] the nodes.
I are Troll
|
|
|
|
|
but this will sort based on something.. what I actually want is just a simple MOVE UP and MOVE DOWN button which will move the row in the DataGrid as well as the actual XML file
|
|
|
|
|
jrahma wrote: what I actually want is just a simple MOVE UP and MOVE DOWN button which will move the row in the DataGrid as well as the actual XML file
Simple as it may sound, it still needs to be programmed. The buttons should do something to the grid, and the XML. Back to Danish;
Danish wrote: I would use XPath or XmlDocument and then rebind the grid.
His answer is completely valid; you can use the XmlDocument-class to manipulate the XML. "Rebind the grid" means that the next step would be to load that XML back into the datagrid.
Another option would be to add a field that says "order", and to sort on that - that way the buttons only need to change a value, as opposed to changing the complete order and structure of the Xml file.
I are Troll
|
|
|
|
|
I have a datagridview bound to a datatable. When I remove a row from the datatable the grid reflects the change, but when I attempted to add a row back in I get an error System Index out of Range? I have tried datagridview1.Refresh() with no luck. What am I missing?
Thanks
|
|
|
|
|
Instead of refresh you can try to rebind the grid after deleting.
(or) if this is a wrong solution a code sample would help a lot to give clear solution.
|
|
|
|
|
Is there an article or code sample showing rebinding? Here is my code:
//Are there rows that need to be deleted?
for (int x = 0; x < dsInvoice.Tables["Invoice"].Rows.Count; x++)
{
if (dsInvoice.Tables["Invoice"].Rows[x]["QTYORD"].ToString() == "0")
{
dsInvoice.Tables["Invoice"].Rows[x].Delete();
dataGridView1.Refresh();
}
}
Thanks for all your help
|
|
|
|
|
|
I don't understand please forgive me. I am new to Datagridview grids. After I remove the row from datatable what do I need to do next? I read through your articles, but I am confused??
|
|
|
|
|
Can you show the code you are using add the row?
|
|
|
|
|
I created a DataSource with a DataTable in it and added it through the wizzard when I added the Grid to my form. When a user enters 0 in the first cell I want to remove that row from the grid.
I hope this helps
Thanks!
|
|
|
|
|
How are you adding the row after deletion? Since you are getting IndexOutOfRange exception, you should check all the indexes you are using while adding the row.
|
|
|
|
|
I am clicking on the first cell in the next available row when I receive the error. When I selected the datatable to use for the grid it created a binding source. When I try to execute the RemoveAt with the binding source it errors out.
Is there an easier way to do this?
|
|
|
|
|
I have never used a wizard for doing something like this. I had set the datasource through code and deleted the row using same code as yours. I added and new row as well and didn't received any error.
|
|
|
|
|
protected void btnAdd_Click(object sender, EventArgs e)
{
Response.Cookies[txtCookieValue.Text].Value = txtCookieValue.Text;
DropDownList1.DataSource = Request.Cookies;
DropDownList1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Cookies.Clear();
Request.Cookies.Clear();
DropDownList1.DataBind();
}
i have executed 1st method many times as to add more and more Cookies
and then i have executed 2nd method ones.This should Clear all items in deopdownlist1. but its not cleared
can anyone tell me why?
|
|
|
|
|
for (int i = 0; i < Response.Cookies.Count; i++)
Response.Cookies[i].Expires = DateTime.Now.AddDays(-1);
for (int i = 0; i < Request.Cookies.Count; i++)
Request.Cookies[i].Expires = DateTime.Now.AddDays(-1);
this is also not working
|
|
|
|
|
string[] c = Request.Cookies.AllKeys;
foreach (string co in c)
{
Response.Cookies[co].Expires = DateTime.Now.AddDays(-1);
}
this is working..
any idea why this approach is right and above 2 are wrong?
|
|
|
|
|
Can anybody explain to me how I handle the DataError Event? I have the
following code but the error does not get picked up by any of them. Looking
at e.Context shows " Parsing | Commit | CurrentCellChange ", how do I get
the individual values?
if (e.Context == DataGridViewDataErrorContexts.Commit)
{
MessageBox.Show("Commit error");
}
if (e.Context == DataGridViewDataErrorContexts.CurrentCellChange)
{
MessageBox.Show("Cell change");
}
if (e.Context == DataGridViewDataErrorContexts.Parsing)
{
MessageBox.Show("parsing error");
}
if (e.Context == DataGridViewDataErrorContexts.LeaveControl)
{
MessageBox.Show("leave control error");
}
|
|
|
|
|
Hi,
DataGridViewDataErrorContexts is an enum and has the FlagsAttribute, which means all members are really bit-oriented flags, so try this:
if ((e.Context & DataGridViewDataErrorContexts.Parsing)!=0) {
MessageBox.Show("parsing error");
}
PS: please use PRE tags to show code, as I did (see the difference?)
|
|
|
|
|
i have one form
this form have some of textbox& have button
if button clicked then we view form that consist of member
i want with Doublieclick IN row of datagrid Form one cell view in text box In Other FORM
HOW?
|
|
|
|
|
There are many ways that you can accomplish this; but one of the simplest is to have a delegate respond to your change.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
how can pass data from Form to Other Form
|
|
|
|
|
HI
Can any one kindly let me know how to generate the API Key for rest ful web services like linkedin, whats the best parctice for generating it, thanks in adavnace, kindly reply ASAP,
regards,
|
|
|
|
|
kingshez wrote: whats the best parctice for generating it
You can't generate it, one has to request it. The API-key of LinkedIn can be obtained here[^].
I are Troll
|
|
|
|