|
I solve my problem. I used QueryString.
Thanks a lot...
|
|
|
|
|
how to fetch contiguous numbers from a string
yogesh
|
|
|
|
|
One at a time ? If you give an example of what you mean, perhaps we can help. If it's a comma seperated list, just use the Split function to turn into a string array. USe int.tryparse if you want them to come out as ints instead of strings.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
i m trying that i have one string "260px" this is got by
panel23.style["top"]..... i m trying to fetch 260 from this string , for further manupulations.
yogesh
|
|
|
|
|
The regular expression "\d{2,}" will match any sequences with two or more digits.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Hi,
Firstly:How can I get MessageBox in ASP.Net Page by using C#.When I am Using Response.Write("alert('Employee ID already Exits');"); Font of my Label's in the ASP.Net page getting changed...
Secondly:I am using Microsoft Access as my Back end.Their I created an Employee table and I am Inserting ,Updating and Deleting the records of that table.Created EMPLOYEE ID as primary key.
What I trying to get is that when I am trying to Insert a Duplicate record (i.e Same Employee ID which is already present)a message Box Show that Record already present.
Regards.,
Deepak
-- modified at 13:08 Tuesday 6th November, 2007
|
|
|
|
|
Deepak Koduri wrote: When I am Using Response.Write("alert('Employee ID already Exits');"); Font of my Label's in the ASP.Net page getting changed...
That's because you are writing out the code before the code of the page. That makes the browser ignore the doctype tag and render the page in quirks mode.
Use the Page.ClientScript.RegisterStartupScript method to put the script in the page.
Deepak Koduri wrote: What I trying to get is that when I am trying to Insert a Duplicate record (i.e Same Employee ID which is already present)a message Box Show that Record already present.
Either check for the id before you add the record, or handle the exception that is the result of trying to add a duplicate id.
Experience is the sum of all the mistakes you have done.
|
|
|
|
|
Hi Guffa.,
How to use this method (Page.ClientScript.RegisterStartupScript)& with which arguments I have to pass in the following code.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class Login : System.Web.UI.Page
{
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=C:\\Project\\DataBase.mdb;Persist Security Info=False;");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
string s = "Select EmpID from Employee where EmpID=@id1;";
con.Open();
OleDbCommand cmd = new OleDbCommand(s, con);
cmd.Parameters.Add("@id1", OleDbType.VarChar);
cmd.Parameters["@id1"].Value = TextBox1.Text;
OleDbDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
Response.Write("alert('Employee ID already Exits');");
}
else
{
string s1 = "insert into Employee values(@id1,@id2,@id3,@id4,@id5,@id6,@id7,@id8,@id9,@id10,@id11,@id12,@id13,@id14);";
con.Open();
OleDbCommand cmd1 = new OleDbCommand(s1, con);
cmd1.Parameters.AddWithValue("@id1", TextBox1.Text);
cmd1.Parameters.AddWithValue("@id2", TextBox2.Text);
cmd1.Parameters.AddWithValue("@id3", TextBox3.Text);
cmd1.Parameters.AddWithValue("@id4", TextBox4.Text);
cmd1.Parameters.AddWithValue("@id5", TextBox5.Text);
cmd1.Parameters.AddWithValue("@id6", TextBox6.Text);
cmd1.Parameters.AddWithValue("@id7", ListBox2.Text);
cmd1.Parameters.AddWithValue("@id8", TextBox7.Text);
cmd1.Parameters.AddWithValue("@id9", ListBox5.Text);
cmd1.Parameters.AddWithValue("@id10", ListBox4.Text);
cmd1.Parameters.AddWithValue("@id11", TextBox8.Text);
cmd1.Parameters.AddWithValue("@id12", BasicDatePicker1.Text);
cmd1.Parameters.AddWithValue("@id13", TextBox9.Text);
cmd1.Parameters.AddWithValue("@id14", ListBox3.Text);
cmd1.ExecuteNonQuery();
//Response.Write("alert('Inserted')");
con.Close();
}
}
private void Write(string p)
{
throw new Exception("The method or operation is not implemented.");
}
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
con.Open();
OleDbCommand cmd = new OleDbCommand("select * from Employee where EmpID=@id1", con);
cmd.Parameters.AddWithValue("@id1", ListBox1.SelectedValue.ToString());
OleDbDataReader dr = cmd.ExecuteReader();
dr.Read();
TextBox1.Text = dr.GetString(0);
TextBox2.Text = dr.GetString(1);
TextBox3.Text = dr.GetString(2);
TextBox4.Text = dr.GetString(3);
TextBox5.Text = dr.GetString(4);
TextBox6.Text = dr.GetString(5);
ListBox2.SelectedValue = dr.GetString(6);
TextBox7.Text = dr.GetString(7);
ListBox5.SelectedValue = dr.GetString(8);
ListBox4.SelectedValue = dr.GetString(9);
TextBox8.Text = dr.GetString(10);
BasicDatePicker1.DayStatusBarText= dr.GetString(11);
TextBox9.Text = dr.GetString(12);
ListBox3.SelectedValue = dr.GetString(13);
con.Close();
}
protected void Button3_Click(object sender, EventArgs e)
{
string s = "Update Employee set Pass=@id2,FName=@id3,LName=@id4,Address=@id5,HomeNo=@id6,Sex=@id7,EmailID=@id8,Designation=@id9,Education=@id10,Skills=@id11,JoinDate=@id12,CProject=@id13,PStatus=@id14 where EmpID=@id1;";
con.Open();
OleDbCommand cmd = new OleDbCommand(s, con);
cmd.Parameters.AddWithValue("@id2", TextBox2.Text);
cmd.Parameters.AddWithValue("@id3", TextBox3.Text);
cmd.Parameters.AddWithValue("@id4", TextBox4.Text);
cmd.Parameters.AddWithValue("@id5", TextBox5.Text);
cmd.Parameters.AddWithValue("@id6", TextBox6.Text);
cmd.Parameters.AddWithValue("@id7", ListBox2.SelectedValue);
cmd.Parameters.AddWithValue("@id8", TextBox7.Text);
cmd.Parameters.AddWithValue("@id9", ListBox5.SelectedValue);
cmd.Parameters.AddWithValue("@id10", ListBox4.SelectedValue);
cmd.Parameters.AddWithValue("@id11", TextBox8.Text);
cmd.Parameters.AddWithValue("@id12", BasicDatePicker1.SelectedDate);
cmd.Parameters.AddWithValue("@id13", TextBox9.Text);
cmd.Parameters.AddWithValue("@id14", ListBox3.SelectedValue);
cmd.Parameters.AddWithValue("@id1", TextBox1.Text);
cmd.ExecuteNonQuery();
//Response.Write("alert('Inserted')");
con.Close();
}
protected void Button4_Click(object sender, EventArgs e)
{
string s = "delete from Employee Where EmpID=@id1;";
con.Open();
OleDbCommand cmd = new OleDbCommand(s, con);
cmd.Parameters.AddWithValue("@id1", TextBox1.Text);
cmd.Parameters.AddWithValue("@id2", TextBox2.Text);
cmd.Parameters.AddWithValue("@id3", TextBox3.Text);
cmd.Parameters.AddWithValue("@id4", TextBox4.Text);
cmd.Parameters.AddWithValue("@id5", TextBox5.Text);
cmd.Parameters.AddWithValue("@id6", TextBox6.Text);
cmd.Parameters.AddWithValue("@id7", ListBox2.Text);
cmd.Parameters.AddWithValue("@id8", TextBox7.Text);
cmd.Parameters.AddWithValue("@id9", ListBox5.Text);
cmd.Parameters.AddWithValue("@id10", ListBox4.Text);
cmd.Parameters.AddWithValue("@id11", TextBox8.Text);
cmd.Parameters.AddWithValue("@id12", BasicDatePicker1.Text);
cmd.Parameters.AddWithValue("@id13", TextBox9.Text);
cmd.Parameters.AddWithValue("@id14", ListBox3.Text);
cmd.ExecuteNonQuery();
//Response.Write("alert('Inserted')");
con.Close();
}
}
Regards.,
Deepak
|
|
|
|
|
I have one form. When I took the Form to ReadOnly state all the controls in the form are need to be in readonly,
A) I have Gridview. How to make this Gridview to ReadOnly. Currently I am doing the gridview.enabled = false. It greyed out the gridview.
B) And I have some validation controls, I want to supress that validations when the form is in Readonly.
Thanks
|
|
|
|
|
A) You have to Navigate through the control Collection of the Gridview and set the property to Read-Only/ENABLED-False.
B) You have to set the Enabled property of the validation controls to false. Page has GetValidators("group") method. Check whether this helps you in some way to disable all the validation controls at once, since it returns the validators to the ValidatorCollection object.
Regards - J O H N -
|
|
|
|
|
i am trying to update row in table (data grid ) but unable to do it .. this is what i have done so far ..
protected void UpdateCommand(object source, DataGridCommandEventArgs e)
{
Response.Write("testing");
SqlConnection conn = new SqlConnection(connectionString);
try
{
conn.Open();
string database1 = "Level1";
TextBox UserName = (TextBox)(e.Item.Cells[2].Controls[0]);
TextBox MacAddr = (TextBox)(e.Item.Cells[3].Controls[0]);
DataSet ds = new DataSet();
SqlCommand myCommand = new SqlCommand("UPDATE " + database1 +
" SET UserName = '" + UserName +
"', MacAddr = '" + MacAddr+" ' ", conn);
myCommand.Connection = conn;
myCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
Response.Write(ex.Message);
Response.End();
if (conn != null) conn.Close();
return;
}
finally
{
Response.Redirect((string)Session["PreviousURL"]);
}
conn.Close();
DataGrid1.EditItemIndex = -1;
can someone help me how to update after we clik edit button in each textbox in a row ??
Thanx !!
-- modified at 11:39 Tuesday 6th November, 2007
|
|
|
|
|
rocky811 wrote: i am trying to update row in sql database
rocky811 wrote: SqlCommand myCommand = new SqlCommand("UPDATE " + database1 +
" SET UserName = '" + UserName +
"', MacAddr = '" + MacAddr+" ' ", conn);
You can't do that unless you understand the Basic's of SQL. I would reccomend you to go through the Basic's Of SQL Commands.[^]
Regards - J O H N -
|
|
|
|
|
can u help me with the above code please ?
|
|
|
|
|
Database doesn't have rows. Only tables in the Database can contain Row's. what is that you are trying to do exactly in that code?
I have sent you a link to Read the Basic's of SQL Command. If you go through it you will understand how to write a UPDATE statement in SQL.
Regards - J O H N -
|
|
|
|
|
sorry !! i mistyped it !!! i actually wanted to update a row in table.. i have a data grid with few columns in it . I want to edit each row and update it . when i try to click edit button it shows an exception (Invalid Operation) . Hope u got it now..
|
|
|
|
|
Here is the syntax of the UPDATE statement used to make changes to the existing records in table.
update tablename<br />
set columnname = newvalue [,columnxname = newvaluex...]<br />
where columnname OPERATOR value [and|or columnnamex OPERATOR valuex]
Compare this syntax with your UPDATE statement and check whether you have given it right.
Regards - J O H N -
|
|
|
|
|
Dear Friends,
How we can keep data after inserting in formview controls?.
When i'm inserting a record formview will fire a method, that method is calling a stored procedure. If Stored Procedure is return error i want to keep data in my formview.
How i can solve this issue?
Haridas.R
harisofttech@gmail.com
harisofttech@hotmail.com (online)
harizeenet@yahoo.co.in(online)
"Achievement is not a destination, its a journey "
|
|
|
|
|
I think having the ViewState Enabled for ur control should solve this problem
try having the EnableViewState=true in ur FormView
or save that record in the session and take it back on return
I hope it helps
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
I am using the Ajax control toolkit TabContainer.
When I place it on the page in design view instead of seeing the Tab control I see a little brown box.
I looks fine when I run the page - it just doesnt display how it will look in the design view.
Am I doing something wrong or is it supposed to be this way ?
Thanks
|
|
|
|
|
Hello everyone,
well I'm working in a module where i'm using a gridview to display data without binding it to it. Now its working but the only problem is that it doesnt sort in alternating ASC/DESC order like normal. I noticed while debugging that I was always getting the SortDirection in the OnSorting event as Ascending.
Is there some other way so that I can make the sorting in the usual Alternating way of ASC and DESC.
Hope u got what I'm saying
<asp:GridView ID="GridView1" runat="server" PageSize="20" DataKeyNames="DirectoryID" AutoGenerateColumns="False" AllowPaging="True"
OnPageIndexChanging="GridView1_PageIndexChanging" OnRowUpdating="GridView1_RowUpdating"
OnRowDeleting="GridView1_RowDeleting" AllowSorting="true" OnSorting="GridView1_OnSorting"
OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowCommand="EditButton_OnRowCommand">
<Columns>
<asp:TemplateField SortExpression="DirectoryID" HeaderText="DirectoryID" Visible="false">
<ItemTemplate>
<asp:Label ID="Label_ID" Text='<%# Eval("DirectoryID") %>' Runat="Server"/>
</ItemTemplate>
</asp:TemplateField>
...
and in the On sorting event I'm doin this
protected void GridView1_OnSorting(object sender, GridViewSortEventArgs e)
{
DataView dv = (DataView)Session["dvVD"];
if (dv != null)
{
//Vendor_Directory vd = new Vendor_Directory();
dv.Sort = e.SortExpression + ((e.SortDirection == SortDirection.Descending) ? " DESC": " ASC");
GridView1.DataSource = dv;
GridView1.DataBind();
}
}
Thanks in advance
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
This article[^] says that Gridview seems to have problem when we do sorting. The Value of SortDirection is always set to "Ascending". But the problem is sorted out having the sort Direction and Sort Expression in the Viewstate. Have a look, it may help you to solve the problem.
Regards - J O H N -
|
|
|
|
|
yes definately there's something wrong here and I'm looking at this article at the moment
http://community.strongcoders.com/content/CSGridViewSortingPaging.aspx
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
YES! I did it with the help of that article I mentioned earlier...
Thanks a lot for ur help John. I appreciate it
Rocky
You can't climb up a ladder with your hands in your pockets.
|
|
|
|
|
you're most welcome.
Regards - J O H N -
|
|
|
|