|
suppose you have an xml file like this
<!--Bookstore XML Example-->
<bookstore>
<genre name="Fiction">
<book isbn="10-861003-324" title="A Tale of Two Cities" price="19.99">
<chapter num="1" name="Introduction">Abstract...</chapter>
<chapter num="2" name="Body">Abstract...</chapter>
</book>
</genre>
</bookstore>
Use XElement.Load(@"yourfilepath");
After you read, you will get the element structure like this:
<bookstore>
<genre name="Fiction">
<book isbn="10-861003-324" title="A Tale of Two Cities" price="19.99">
<chapter num="1" name="Introduction">Abstract...</chapter>
<chapter num="2" name="Body">Abstract...</chapter>
</book>
</genre>
</bookstore>
You can also make use of
XDocument xdoc = XDocument.Load("your path");
if you need comments and declarations ...
Abhishek Sur
My Latest Articles
Basics on LINQ and Lambda Expressions
Create .NET Templates
<div class="ForumMod">modified on Wednesday, March 4, 2009 6:30 AM</div>
|
|
|
|
|
initially i created a table and inserted some data and connected to that table. i took 2 labels and 2 textboxes and a button. one for username and one more for password . in button_click i wrote the code as following
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection("Data Source=SVIADV;Initial Catalog=my database;User ID=sa;Password=sqlserver");
SqlCommand cm = new SqlCommand("select count(*)from myusers where username= TextBox1.Text and password=TextBox2",cn);
cn.Open();
int i = Convert.ToInt32(cm.ExecuteScalar());
cn.Close();
if (i == 0)
{
Response.Write("<b> invalid username/password</b>");
}
else
{
HttpCookie c = new HttpCookie("n", TextBox1.Text);
Session["n"] = TextBox1.Text;
Response.Redirect("default2.aspx");
}
}
}
|
|
|
|
|
Great ,u done this much.Good work
|
|
|
|
|
Whats your Doubt? Specify the doubt?
|
|
|
|
|
Well, there's a bug in your sql string though.
Not sure it's gonna run without the space after count(*).
Plus!
I'm pretty sure the column username would be an nvarchar, as most likely would the column password.
Hence, you have to use inverted commas. (').
BUT.
The best way yet to do it would be to add parameters to it instead, like so:
SqlCommand cm = new SqlCommand("select count(*) from myusers where username= @usrnm and password=@password",cn);
cm.Parameters.Add("@usrnm", SqlDbType.NVarChar).Value = textBox1.Text;
cm.Parameters.Add("@password", SqlDbType.NVarChar).Value = textBox2.Text;
Now try it
var question = (_2b || !(_2b));
modified on Wednesday, March 4, 2009 6:00 AM
|
|
|
|
|
aratireddy wrote: initially i created a table and inserted some data and connected to that table. i took 2 labels and 2 textboxes and a button. one for username and one more for password . in button_click i wrote the code as following
then what is your problem?
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Hi, I use Gridview in my form. The code is as follows.
<asp:gridview id="view1" autogeneratecolumns="false" allowpaging="True" xmlns:asp="#unknown">
OnRowCommand="GridView1_RowCommand" runat="server" CellPadding="4"
ForeColor="#333333" GridLines="None" OnSelectedIndexChanged="view1_SelectedIndexChanged">
But at runtime the following erroe came.
The data source does not support server-side data paging.
Can anyone tell what the problem?
|
|
|
|
|
|
S. I got the solution. Now i want to display some 10 rows in grid view. And at the bottom of the grid the Page numbers are to be displayed. If i clicked the Second page again the rows from 2nd page has to display?How to achieve it?
|
|
|
|
|
make the gridview paging property true and fire the event of grid view paging.
follow the code.set the column properties 10.
eg.
{
protected void grdemp_PageIndexChanging(object sender, GridViewPageEventArgs e)
//grdemp is ame of grid view
{
grdemp.PageIndex = e.NewPageIndex;
}
}
Regards
Keyur Satyadev
|
|
|
|
|
i work on your code. But the following error came. Can u solve it?
The GridView 'view1' fired event PageIndexChanging which wasn't handled
|
|
|
|
|
i think you use the view in your code so make event for it.
or send me your code so i make correct it?
regards
keyur satyadev
|
|
|
|
|
<asp:gridview id="view1" autogeneratecolumns="false" allowpaging="true" allowsorting="true" xmlns:asp="#unknown">
OnRowCommand="GridView1_RowCommand" runat="server" CellPadding="4"
ForeColor="#333333" GridLines="None" PageSize="2">
<columns>
<asp:templatefield headertext="Job-ID">
<itemtemplate>
<asp:linkbutton id="lblId" runat="server">
CommandArgument='<%# Eval("jid") %>' CommandName="getid"
Text='<%# Bind("jid") %>'>
<headerstyle horizontalalign="Center">
<asp:templatefield headertext="Title">
<itemtemplate>
<asp:label id="lbltit" runat="server" text="<%# Bind(" title=") %>">
<headerstyle horizontalalign="Center">
<asp:templatefield headertext="Description">
<itemtemplate>
<asp:label id="lbldes" runat="server" text="<%# Bind(" description=") %>">
<headerstyle horizontalalign="Center">
In th COde behind i write the following code
protected void view1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
view1.PageIndex = e.NewPageIndex;
}
Whats the error in this?
|
|
|
|
|
please write event name in gridview property.
<asp:gridview id="view1" pageindexchanging="view1_PageIndexChanging" xmlns:asp="#unknown">
|
|
|
|
|
Again the same error. What to do?
<asp:gridview id="view1" xmlns:asp="#unknown">pageindexchanging="view1_PageIndexChanging"
AutoGenerateColumns="false" AllowPaging="true" AllowSorting="true"
OnRowCommand="GridView1_RowCommand" runat="server" CellPadding="4" xmlns:asp="#unknown"
ForeColor="#333333" GridLines="None" PageSize="5">
The GridView 'view1' fired event PageIndexChanging which wasn't handled.
|
|
|
|
|
bind urs grid on page index changing also...call grid bind functin here also..
|
|
|
|
|
write the code of your data binding in paging event again.
|
|
|
|
|
Hi
I have a textbox on page that should be numeric and non zero
What can we set the ValidationExpression to validation control
|
|
|
|
|
You can use this javascript function
Place a HTML text box (here its name is Text1)and onBlur event write a function
function abc()
{
var res=document.getElementById("Text1").value;
if(isNaN(res)|| document.getElementById("Text1").value==0)
{
document.form1.Text1.value="";
}
}
modified on Wednesday, March 4, 2009 5:28 AM
|
|
|
|
|
Put the validation expression as
validationexpression=\d{0,10}
its only accepting only integer values in the range 0 to 10
or Change it to
ValidationExpression="[0-9]*"
<asp:regularexpressionvalidator id="RegularExpressionValidator1" runat="server" controltovalidate="TextBox1" errormessage="Please Enter only Numeric" validationexpression="[0-9]*" xmlns:asp="#unknown">
SAJAN A PILLAI
ASP.NET,C#.NET Programmer
BANGALORE
"Winners don't do different things. They do things differently. ...
modified on Wednesday, March 4, 2009 5:25 AM
|
|
|
|
|
I want accecpt all integer and non zero
|
|
|
|
|
You could use a comparevalidator to check the value is greater than 0
|
|
|
|
|
You can use regex to find if the entered data is a "Natural Number". Google will help you find it.
Also, make sure that the regex should NOT have a check that text begins with 0. Reason being user can enter 0000003434 which is a valid entry as per your criteria.
Time is the best teacher; unfortunately it kills all of its students.
जय हिंद
|
|
|
|
|
Hi.
For a GridView, how to retrieve the cell values of a selected row?
Thank you!
|
|
|
|
|
You asked this question before and I gave you the answer.
The reason why it could not have worked for you is most likely your setting a row's state as Selected wrong.
My question therefore: how do you select the row, in other words, what code do you exectue in the application, so that it recognizes your desired row as .SelectedRow.
Looking at it very hard or highlighting is not the right way.
Usually, where you actually do Select a row, getting data from it is really, really easy.
string something = Gridview1.SelectedRow.Cells[0].Text;
Honestly, do post some more information, maybe some code of your own if you want people's replies to be relevant.
var question = (_2b || !(_2b));
|
|
|
|