Its possible Create text box through code like Dim CustIDTextBox As TextBox=MyGridView.Rows(e.RowIndex).cells(0).controls(0)
2008/12/23 Brock <[email protected]> > > Ideally what I would like to do is to have instead of a details view > just 3 textboxes that would populate and be editable upon double > clicking a row in my datagrid... is this possible? I tried dragging a > detailsview from my toolbox into a panel below my datagrid > (detailsview is new to me as I've been in Framework 1.1 for a while). > I view the page in the browser and no detailsview appears (?) > > On Dec 22, 2:24 pm, Cerebrus <[email protected]> wrote: > > You seem to have made considerable progress... but in a direction > > where the use of the XPathNavigator becomes a moot point. Overlooking > > the performance considerations of your code, I'd just say that when > > you are using a DataSet/DataView, it becomes much more straightforward > > to use the DataTable methods to add/edit/delete records and finally > > save the XML using the WriteXML method. The XPathNavigator or > > XmlDocument would be relevant only if we were dealing directly with > > XML data in memory. > > > > Assuming the following : > > 1. This is the code in the "details" page > > 2. The eventID is the Primary key that uniquely identifies each Event. > > 3. You've already passed the eventID of the topic to be edited to the > > "details" page using the DataGrid.DataKeys > > (DataGridCommandEventArgs.ItemIndex) method via the Querystring. > > ... > > You can simply "find" the Row in your DataTable that is being edited > > using the DataTable.Find() method, passing the eventID received above. > > This should return a DataRow. This DataRow will expose properties > > that allow each of the column values to be edited, much the same way > > as you are adding a NewRow. > > > > On Dec 22, 9:21 pm, Brock <[email protected]> wrote: > > > > > > > > > Below is the XML file I'm using which is popualting my grid > > > successfully: > > > > > (Ideally I would like to avoid using buttons on my grid and attaching > > > an event handler for double-clicking a displayed row on the grid.) > > > > > I have this code wich is working well at adding "topics" to my XML > > > file, but on using XPathNavigator to edit, I'm lost on that one: > > > > > Private Sub btnSubmit_Click(ByVal sender As System.Object, _ > > > ByVal e As System.EventArgs) Handles btnSubmit.Click > > > Using ds As New DataSet() > > > ds.ReadXml(Server.MapPath("history.xml")) > > > Dim dr As DataRow = ds.Tables(0).NewRow() > > > dr("eventID") = txtEventID.Text > > > dr("event") = txtNewEvent.Text > > > dr("year") = txtDate.Text > > > ds.Tables(0).Rows.Add(dr) > > > ds.WriteXml(Server.MapPath("history.xml")) > > > End Using > > > End Sub > > > > > <?xml version="1.0" standalone="yes"?> > > > <events> > > > <topic> > > > <eventID>1001</eventID> > > > <event>Bay of Pigs</event> > > > <year>1961</year> > > > </topic> > > > <topic> > > > <eventID>1002</eventID> > > > <event>Vienna Summit with Soviet Premier Nikita Kruschev</event> > > > <year>1961</year> > > > </topic> > > > <topic> > > > <eventID>1003</eventID> > > > <event>Cuban Missle Crisis</event> > > > <year>1962</year> > > > </topic> > > > </events> > > > > > On Dec 17, 2:20 pm, Cerebrus <[email protected]> wrote: > > > > > > On Dec 17, 1:23 am, Brock <[email protected]> wrote: > > > > > > > Thanks Cerebus... you're the best > > > > > > I'm also the most absent minded. I forgot all about your data being > > > > XML halfway through writing my reply. :P > > > > > > On second thoughts, however, maybe that impression was propagated by > > > > your use of a DataView. IMO, you can directly bind a Datagrid to an > > > > XML file (eg, using XmlDataSource) without going through the XML -> > > > > DataSet -> DataView route. > > > > > > > I think the Querystring is my best bet with a details view on > > > > > another .aspx page. > > > > > I've had a devil of a time finding any textbook examples or web > > > > > resources for embedding > > > > > SELECT-FROM-WHERE type sql querying to choose a particular node of > the > > > > > XML file > > > > > and make the node's data accessible to the new .aspx page through a > > > > > querystring. > > > > > I've seen some reference to the "FOR XML AUTO" phrase but I'm not > sure > > > > > if that > > > > > is on the right track (?). Any examples in websites would be very > > > > > helpful. This is not part of my job > > > > > but I just personally want to learn how to query into XML files to > > > > > grab "records/nodes", edit them, delete, etc. > > > > > I use vb.net and know nothing of C# (us vbers are "parenthetically > > > > > challenged", pardon my humor!) > > > > > > Since we're selecting XML, our best bet is to use .NET's built in > > > > capabilities for selecting and querying XML. Use the XPathNavigator > > > > with an appropriate XPath expression. (If you have trouble with this > > > > part, post the XML and what you want to select) to return another > > > > XPathNavigator that can be assigned to the Datasource property of the > > > > FormView / DetailsView.- Hide quoted text - > > > > > > - Show quoted text -- Hide quoted text - > > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text - -- Regards ******************* *C.Arun Kumar * *******************
