|
|
Thank u so much for ur fast reply,
But if u dont mind can u plz send me the code as to how to do that.Please.I understood what u told but i dont know how to do it.
Vipin
|
|
|
|
|
You could just add a bound column that displays the primary key from the database, obviously this assumes your datasource is a db query.
|
|
|
|
|
Hey guys iw as wondering if someone could help me. I am trying to execute a sql query when i visit the site and display the results in xml format. I am able to go as far as filling the results into the dataset but i don't know how to Display the results as xml on the page.
#region Strings
string command = "SELECT DES from [DATABASE]";
#endregion
SqlConnection dataConnection = new SqlConnection();
dataConnection.ConnectionString = @"Data Source=ADMINPC\SQLExpress;Initial Catalog=warezdb;Integrated Security=True";
SqlCommand sqlcommand = new SqlCommand(command, dataConnection);
SqlDataAdapter adapter = new SqlDataAdapter(sqlcommand);
DataSet pubs = new DataSet();
#region Execute
try
{
dataConnection.Open();
adapter.Fill(pubs);
}
catch (Exception er)
{
Response.Write(er.Message);
}
finally
{
dataConnection.Close();
}
#endregion
Thanks In Advance For Your Help,
TeeJay
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
+ Use the DataSet.GetXml[^] method to get data stored in the dataset in xml format.
+ Write out the result to the outputstream of the Response object, you may also sepcify the ContentType of the output as text/xml .
|
|
|
|
|
thanks man i appreciate it
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Hi! I want to do a report generation, when the user click the view report button, the datagrid will be transfered to another webform in C#.
I am using code behind. Here is the partial code for frm_First.aspx.cs. (Assuming I have connected the database to the datgrid)
<code>private void display()
{
..........
this.GridData = this.dgDisplay.DataSource;
..........
}
private void btnReport_Click(object sender, System.EventArgs e)
{
Server.Transfer("frm_Report.aspx");
}
public object GridData
{
set
{
this.gridData = value;
}
get
{
return this.gridData;
}
}
Whereas at the frm_Report,
namespace project
{
public class frm_Report : System.Web.UI.Page
{
......................
project.frm_First objSendingPage;
private void Page_Load(object sender, System.EventArgs e)
{
this.objSendingPage = new frm_First();
receivingDG.DataSource = objSendingPage.GridData;
receivingDG.DataBind();
}
}</code>
thanks in advance. Much appreciated.
-- modified at 21:24 Wednesday 5th July, 2006
|
|
|
|
|
blurMember wrote: this.objSendingPage = new frm_First();
To get reference to the source page, you basically cast the Context.Handler to the source page type. In the ASP.NET 2.0, you can use the Page.PreviousPage property.
|
|
|
|
|
Is the method like this?
private void Page_Load(object sender, System.EventArgs e) <br />
{<br />
if (!IsPostBack) <br />
{<br />
<br />
}<br />
objSendingPage = ((frm_ShowAttd)(Context.Handler));<br />
this.objSendingPage = new frm_ShowAttd();<br />
receivingDG.DataSource = objSendingPage.GridData;<br />
receivingDG.DataBind();<br />
}
thanks in advance. Much appreciated.
|
|
|
|
|
blurMember wrote: objSendingPage = ((frm_ShowAttd)(Context.Handler));
//this.objSendingPage = new frm_ShowAttd();
receivingDG.DataSource = objSendingPage.GridData;
receivingDG.DataBind();
You should comment out the second line as it initializes a new object.
|
|
|
|
|
Thanks. I have deleted the second line. But the same problem occur. The frm_Report stubborn to display the data in the datagrid. Have I done something wrong?
namespace project<br />
{<br />
public class frm_Report : System.Web.UI.Page<br />
{<br />
......................<br />
project.frm_First objSendingPage;<br />
<br />
private void Page_Load(object sender, System.EventArgs e) <br />
{<br />
if (!IsPostBack) <br />
{<br />
}<br />
objSendingPage = ((frm_ShowAttd)(Context.Handler));<br />
receivingDG.DataSource = objSendingPage.GridData;<br />
receivingDG.DataBind();<br />
}
The code at the frm_First.aspx.cs remain the same:
namespace project
{
public class frm_First : System.Web.UI.Page
{
.............
private object gridData;
}
......
}
Followed by the earlier code I commented.
thanks in advance. Much appreciated.
-- modified at 2:35 Thursday 6th July, 2006
|
|
|
|
|
blurMember wrote: But the same problem occur.
+ What is the problem? You didn't mention it IIRC.
+ How do you set the GridData property in the source page?
+ You can debug your application and step through your code in the Page_Load event handler.
|
|
|
|
|
+ What is the problem? You didn't mention it IIRC.
The problem is when I click the btnReport, the frm_Report page retrieves blank.
+ How do you set the GridData property in the source page?
Set the GridData? Like this? (Refer below)
public object GridData <br />
{<br />
set<br />
{<br />
this.gridData = value; <br />
}<br />
get <br />
inside a dataset<br />
return this.gridData;<br />
}<br />
}
thanks in advance. Much appreciated.
|
|
|
|
|
blurMember wrote: the frm_Report page retrieves blank.
Looks like the datasource bound to the grid control is empty (or null).
blurMember wrote: Set the GridData? Like this? (Refer below)
public object GridData
{
set
{
this.gridData = value;
}
get
inside a dataset
return this.gridData;
}
}
No, I mean how do you set the GridData property (or the gridData instance) in the source page? Do you populate it on postback when the button is clicked? If you don't, the property will be empty, and the grid will display nothing on the web page.
|
|
|
|
|
Sorry I don't understand. I don't think I set the GridData property. And I think I never populate it on postback. It may sound simple to you, but how do I go about doing that?
thanks in advance. Much appreciated.
|
|
|
|
|
blurMember wrote: And I think I never populate it on postback. It may sound simple to you, but how do I go about doing that?
It means, in the first form frm_First, you normally populate the datasource to bind to the dgDisplay datagrid only for the first time, but here you need to access this datasource in the second form with the Server.Transfer method when the button is clicked, you need to populate the datasource in the frm_First again. In a short answer, you need make sure that the GridData property is assigned a value in the first form so that you can access it in the second form after the Server.Transfer method executes. If you still don;t understand, you can post your sample code in the first form, I'll point out your issue.
|
|
|
|
|
blurMember wrote: this.dgDisplay.DataSource=ds;
this.GridData = this.dgDisplay.DataSource;
this.dgDisplay.DataBind();
That's enough. So here you populate the dataset ds and bind it to the grid control in the ShowAllWeek method, you then assign the datagrid's DataSource property to the GridData property of the web page, and I think that the ShowAllWeek does not execute when you hit the button. To fix this code, I suggest you saparate to your code to populate the dataset object in a seperate method, say BuildDataSource, which returns the result populated dataset ds . In the Page_Load of the first form, you can write your code like this:
private void Page_Load(object sender, System.EventArgs e)
{
DataSet ds = BuildDataSource();
this.GridData = ds;
if(!IsPostBack())
{
this.dgDisplay.DataSource=ds;
this.dgDisplay.DataBind();
}
}
|
|
|
|
|
Thank you very much for your help. I realised that if I called the function ShowAllWeek from the Page_Load . The datagrid is able to be transfer the information to another webform. I am confused for the reason it happened it that manner.
You mentioned earlier about BuildDataSource() . Is this correct?
public BuildDataSource()<br />
{<br />
DataSet ds = new DataSet();<br />
this.dgDisplay.DataSource=ds;<br />
this.GridData = this.dgDisplay.DataSource;<br />
this.dgDisplay.DataBind();<br />
}
I know I am extremely weak.
thanks in advance. Much appreciated.
|
|
|
|
|
blurMember wrote: I realised that if I called the function ShowAllWeek from the Page_Load. The datagrid is able to be transfer the information to another webform. I am confused for the reason it happened it that manner.
It's simple, calling the ShowAllWeek method in the Page_Load makes sure that the you bind the datasource again to the grid, and the GridData is assigned the value also.
|
|
|
|
|
I have 2 forms. I am using form1 as my parent and form2 as a child form. I also have a class (clBuffer) name of my class. In my class(clBuffer.cs) i have 4 strings. How do I send value to those strings from parent class, and how do I read them from the child class?
Thanks
|
|
|
|
|
oskardiazdeleon wrote: I am using form1 as my parent and form2 as a child form.
Are they related to in term of inheritance? Basically, you can pass the reference of the clBuffer object from one class to another, so that you can access it from the other class. Another option is that the second class may have access to the first class.
|
|
|
|
|
See my reply in the C# forum.
Be advised, though, that using static variables in a web application means that all users share the same variable.
---
b { font-weight: normal; }
|
|
|
|
|
Can you pass attributes using the hypertext link. e.g
P. R Inc
-- modified at 12:36 Wednesday 5th July, 2006
|
|
|
|
|
Which attributes do you mean? Where do you want to pass them to? Could you be more specific about your context?
|
|
|
|
|
Hello,
I am trying to create a simple link (static) to an access database in my web application. I have removed .mdb extension from the application extensions menu in iis, but every time I run the app and click on this link I get the following error:
The process cannot access the file 'D:\...\accessdb.mdb' because it is being used by another process.
Some googling suggested that maybe .net has cached the file (it's over 30 mb), and has locked it. Can this be prevented? Any help would be appreciated. I'm really spinning my wheels with this one.
Thanks
|
|
|
|