|
Hi
I have written the following asp.net page and creating the xml file through a method everything is fine it is creating the file but i have a problem. May be you can help for that. it is about the xml file output when it created it showing TABLE and TABLE1 as node in xml how i can change it to meaningful name. My Code is as follows. XML file is at the bottom of the code
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Xml;
using System.IO;
public partial class _Default : System.Web.UI.Page
{protected void Page_Load(object sender, EventArgs e){
GetEmployees("London");
}
public static void GetEmployees(string City){
//String sConnection = "server=HTCWEBDEMO;database=hometrust;user id=ht_admin;password=htc_tr!st";
String sConnection = "server=ZAFAR-PC\\SQLEXPRESS;Integrated Security=SSPI;database=northwind";
SqlConnection mySqlConnection = new SqlConnection(sConnection);
mySqlConnection.Open();
// Get the same data through the provider.
//string mySQLStatement = "SELECT Title,FirstName,LastName,PhoneNumber,Faxnumber, email from contactlist where TeamName='" + TeamName +"'; select FirstName, LastName from contactlist where TeamMorty ='True' and teamname='" + TeamName + "';";
string mySQLStatement = "SELECT FirstName,LastName,Title,City from employees where city= '" + City + "';select FirstName, LastName from employees where city='" + City + "';";
//SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySQLStatement, sConnection);
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySQLStatement, sConnection);
DataSet myDataSet2 = new DataSet();
myDataSet2.DataSetName = "Contacts";
mySqlDataAdapter.Fill(myDataSet2);
// Write data to files: data1.xml and data2.xml for comparison.
myDataSet2.WriteXml("c:/temp/ContactList.xml");
mySqlConnection.Close();
}
}
XML FILE OUTPUT
<?xml version="1.0" standalone="yes" ?>
- <Contacts>
- <Table>
<FirstName>Steven</FirstName>
<LastName>Buchanan</LastName>
<Title>Sales Manager</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Michael</FirstName>
<LastName>Suyama</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Robert</FirstName>
<LastName>King</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Anne</FirstName>
<LastName>Dodsworth</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table1>
<FirstName>Steven</FirstName>
<LastName>Buchanan</LastName>
</Table1>
- <Table1>
<FirstName>Michael</FirstName>
<LastName>Suyama</LastName>
</Table1>
- <Table1>
<FirstName>Robert</FirstName>
<LastName>King</LastName>
</Table1>
- <Table1>
<FirstName>Anne</FirstName>
<LastName>Dodsworth</LastName>
</Table1>
</Contacts>
|
|
|
|
|
Hello All,
I am beginner in ASP .NET
I had used SQL2000, GridView and SQLDataSource. While creating SQDataSource1 query was mentioned "Select top 5 EmployeeId, FirstName from Employee". As page is loaded it show data without error.
Now I had added button on its click event I had used mentioned query "Select top 5 ProductId, ProductName from Product".
My question is can again GridView can be bind with DataKeyNames. If yes how can i do it. I had try code in vb & c#. Please help.
Thanks in advance
Shazz here to help you...
|
|
|
|
|
hi,
do you want to bind the grid with product columns now? I think not possible, I think you should call a user control on click event, use grid view on that control and bind your product columns on that.
|
|
|
|
|
Hi..
I am building a asp.net based website and i am using C# and VB both in this project. I am confused about the web.config setting. In order to go with two languages what settings need to be done in web.config?
|
|
|
|
|
Hi all,
I want to use a DropDownList control and set this property
In Page_Load event:
ddl.DataTextField="Adminicle";
ddl.DataValueField="CodeAdminicle";
ddl.DataBind();
In SelectedIndexChanged event:
row=ddl.SelectedItem.Value
but no row was selected.
what should i do?
|
|
|
|
|
Set 0 index value as default after the bind. Please be ensue list should be 1 value.
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|
|
This is example,
//This is one way to u should bind to dropdown with list.
foreach(string text in TextList)
{
dropdown.Item.Add(new ListItem(text.Name.ToString(),text.ID.ToString()));
}
//when u select value from dropdown,in the selectedIndexChanged Event
string value=dropdown.SelectedValue.ToString();
may be this will help u.
|
|
|
|
|
Hy,
I have created a email page by using the following code
MailMessage msg = new MailMessage();
msg.To = txtTo.Text;
msg.From = txtFrom.Text;
msg.Subject = txtSubject.Text;
msg.Body = txtContent.Value;
lblStatus.Text = "Sending...";
SmtpMail.Send(msg);
but when i run the page the mail is not sent....
do i have to use SmtpMail.SmtpServer for sending the mail?
plz help...
regards
|
|
|
|
|
first of all you have to Configure your SMTP Server for sending mail.
raghvendrapanda wrote: msg.To = txtTo.Text;
You can't do like this, because its take only type of MailAddress or MailAddressCollection object.
So use
msg.To=new MailAddress(TxtTo.Text)
For sending Mail
SmtpClient _smtServer=new SmtpClient("MyServer");
_smtServer.Send(msg);
cheers,
Abhijit
|
|
|
|
|
Hy,
Thankz for replying to my querry..but can u tell me that how can i Configure my SMTP Server for sending mail.
|
|
|
|
|
|
Hy,
I configured the SMTP but it didnt help...I found a virtual directory where a default setting was present ..on tracking i found all my mail where stored in a folder(C:\Inetpub\mailroot\Queue)..and were not sent to the mail..what sholud i do in order to send them?
you suggested me a code..
SmtpClient _smtServer = new SmtpClient("MyServer");
when i used this i get an exception that mail sending failed..
|
|
|
|
|
raghvendrapanda wrote: SmtpClient _smtServer = new SmtpClient("MyServer");
Did you put your SMTP server name over "MyServer"
cheers,
Abhijit
|
|
|
|
|
Hy,
i changed Myserver to local host and de mail got stored in C:\Inetpub\mailroot\Queue..
i created a new remote domain and named it gmail.com ..And dn i added "RemoteServer" instead of MYSERVER .itz execution was sucessful..But again it went and got stored in.C:\Inetpub\mailroot\Queue.. (if i want to send my mail to gmail.com what should i do?)..Do i have to use sum other server for dis?or server permission is required?
|
|
|
|
|
Check your web.config file as far as my knowledge is concern we mention port number in web.config.
Shazz here to help you...
|
|
|
|
|
Hi,
I have placed and asp:Timer control in gridview and the whole gridview is inside an update panel.
I m getting error that the timer control needs a scriptmanager on the page. I have the scripmanager on the masterpage.
When I m creating the timer control outsite the gridview its working nice.
When running the code the updatepanel trigger is throwing error that control with id of the timer is not found.
Can anyone help??
Regards
Vijay V.
Yash Softech
|
|
|
|
|
for (int j = k+2; j <= i + DaysinMonth - 2; j++)
{
//"TextBox" + j.Text = firstDay.Day + 1;
}
The id of textbox on my form is like TextBox1,TextBox2,TextBox3, TextBox4 etc .
In the loop i want to generate id of Textbox and then assigning value into that.
Can any one tell me the correct statement which i have commented in my code.
Regards'
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
{
TextBox[] _objTxt = new TextBox[10] ;
for (int i = 0; i < 10; i++)
{
_objTxt[i] = new TextBox();
_objTxt[i].ID = "TextBox" + i.ToString();
_objTxt[i].Text = "My ID Is " + i.ToString();
Panel1.Controls.Add(_objTxt[i]);
}
}
cheers,
Abhijit
|
|
|
|
|
Why This is a Bad Answer ?
Then put you answer
cheers,
Abhijit
|
|
|
|
|
I have marked it as bad answer in the sense that it doesnot fulfill my requirement.You are creating TextBox control at runtime.
But i am not creating the control at runtime.I have created Textbox controls and set their id as TextBox1,Textbox2,Textbox3 etc.
Here is the code.
for (int j = k+2; j <= i + DaysinMonth - 2; j++)
{
string a = j.ToString();
string s2 = string.Concat("TextBox", a);
}
Ex:s2 contains Textbox9.
I want to assign the value into the Text of TextBox9.
How can i do this.Please help.
|
|
|
|
|
First of all Sorry For My Misunderstanding of your question.
Now I have some query regarding your question,
You have some textbox ,having ID as TextBox1,TextBox2 etc..
raghvendrapanda wrote: Here is the code.
for (int j = k+2; j <= i + DaysinMonth - 2; j++)
{
string a = j.ToString();
string s2 = string.Concat("TextBox", a);
}
This Give
s2="TextBox9"
raghvendrapanda wrote: I want to assign the value into the Text of TextBox9.
Now You want to Asign that S2 Value to TextBox9 and Similiar if s2 value is TextBox8, then TextBox8 wiill contain S2 value ?
isnt it?
cheers,
Abhijit
|
|
|
|
|
First of all thanks for cooperation.
But i have solved my problem.the solution is as follows.
for (int j = i; j <= i+ DaysinMonth ; j++,k=(k+2))
{
string a = k.ToString();
string s2 = string.Concat("TextBox", a);
TextBox myTextBox = (TextBox)FindControl(s2);
myTextBox.Text = Convert.ToString(firstDay.Day+1);
}
Thanks once again
Regards
|
|
|
|
|
good job !!!
cheers,
Abhijit
|
|
|
|
|
Hi,
can anyone suggest me how to find a control in gridview and pass value on the control using javascript.
I m a newbie with javascript.
Regards
Vijay V.
Yash Softech
|
|
|
|
|
You can’t find server side control in client side. While rendering page, those are converted to HTML markups. To access this HTML tags, use document.getElementById function.
|
|
|
|