|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Access asp:SqlDataSource or asp:GridView directlyshown below. Is there no easier way? I would like to access either asp:SqlDataSource (me.SqlDataSource1.something) or asp:GridView (me.GridView1.something) instead I have to create a new sqlcon,selectcommand,dataset,dataadapter.... Is there no easier way? Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) 'too much code? Dim conSave As New System.Data.SqlClient.SqlConnection(Me.SqlDataSource1.ConnectionString) conSave.Open() Dim strSQL As String Dim dsSave As New Data.DataSet Dim daSave As New Data.SqlClient.SqlDataAdapter strSQL = Me.SqlDataSource1.SelectCommand.ToString daSave.SelectCommand = New System.Data.SqlClient.SqlCommand(strSQL, conSave) daSave.Fill(dsSave) 'too much code! dsSave.WriteXml("C:\SomeXMLFile.xml") End Sub Saturnius
I don't see any GridView in your code? You are saving a file that you have got from a database. Cor <saturn***@gmx.net> schreef in bericht Show quoteHide quote news:1160077171.762023.316080@c28g2000cwb.googlegroups.com... > Hello, I have to save the data from a gridview as XML file. The code is > shown below. Is there no easier way? I would like to access either > asp:SqlDataSource (me.SqlDataSource1.something) or asp:GridView > (me.GridView1.something) instead I have to create a new > sqlcon,selectcommand,dataset,dataadapter.... > > Is there no easier way? > > > > Protected Sub Button1_Click(ByVal sender As Object, ByVal e As > System.EventArgs) > > 'too much code? > > Dim conSave As New > System.Data.SqlClient.SqlConnection(Me.SqlDataSource1.ConnectionString) > conSave.Open() > Dim strSQL As String > Dim dsSave As New Data.DataSet > Dim daSave As New Data.SqlClient.SqlDataAdapter > strSQL = Me.SqlDataSource1.SelectCommand.ToString > daSave.SelectCommand = New System.Data.SqlClient.SqlCommand(strSQL, > conSave) > daSave.Fill(dsSave) > > 'too much code! > > dsSave.WriteXml("C:\SomeXMLFile.xml") > End Sub > Hello Cor,
I just jused drag and drop in Visual Web developer for asp:SqlDataSource and asp:GridView - nothing else. The code behind a button is shown above. I am just looking for a better solution to save the xml file based on the gridview. But I can not figure out how to access the gridview that I have on my page, instead I have to pull the data again from the db. I would like to replace the code between my comments by accessing the gridview/sqldatasource. Thanks, Saturnius Saturnius,
I know no other answer that putting the data you put in your gridview in advance in a seesion. Than you can interact with the key presses or what else with that gridview. The session gives you than the current data in the gridview. Cor <saturn***@gmx.net> schreef in bericht Show quoteHide quote news:1160164186.916976.150340@k70g2000cwa.googlegroups.com... > Hello Cor, > I just jused drag and drop in Visual Web developer for > asp:SqlDataSource and asp:GridView - nothing else. The code behind a > button is shown above. I am just looking for a better solution to save > the xml file based on the gridview. But I can not figure out how to > access the gridview that I have on my page, instead I have to pull the > data again from the db. I would like to replace the code between my > comments by accessing the gridview/sqldatasource. > > Thanks, > Saturnius > Hi Cor,
thank you for the answer. I guess I will stick with my "pulling twice" ..... Thanks! Saturnius Cor Ligthert [MVP] wrote: Show quoteHide quote > Saturnius, > > I know no other answer that putting the data you put in your gridview in > advance in a seesion. > Than you can interact with the key presses or what else with that gridview. > > The session gives you than the current data in the gridview. > > Cor > > <saturn***@gmx.net> schreef in bericht > news:1160164186.916976.150340@k70g2000cwa.googlegroups.com... > > Hello Cor, > > I just jused drag and drop in Visual Web developer for > > asp:SqlDataSource and asp:GridView - nothing else. The code behind a > > button is shown above. I am just looking for a better solution to save > > the xml file based on the gridview. But I can not figure out how to > > access the gridview that I have on my page, instead I have to pull the > > data again from the db. I would like to replace the code between my > > comments by accessing the gridview/sqldatasource. > > > > Thanks, > > Saturnius > >
Help with encrypted web pages?
Thread, UI update is this ok? Redim Multidimenional Arrays declaring a dataset as public Importing DLLs during runtime Can a custom object know it's owner PrintPreviewDialog Control and HTML Drag Bitmap tutorial/code anywhere? search user in active directory Can I create controls with static ID's? |
|||||||||||||||||||||||