|
Hw abt setting the datasource=null
provided u are using the datasource property for binding the listbox.
|
|
|
|
|
sanjubaba wrote: currently my listbox contains about 5000 records
You can clear the list box just set the datasource as null if you are binding the list from data source.
But, My questions is that why you are binding this amount of Records with your List ? This is seriouly impact performance.
Thanks !
|
|
|
|
|
hi, iam using asp.net2.0 with c#, with backend sql server2000
in my client system i have to create dynamically procedure and return the result
but when iam using in my local system the code is working fine but at client system it it not working can you correct my code which helps me
string strcon = "Data Source=";strcon += Request.Params["REMOTE_ADDR"] + ";" + "Initial Catalog=POS;User ID=sa;Password=xx103";
SqlConnection conproc = new SqlConnection(strcon);
conproc.Open();
SqlCommand cmdproc = new SqlCommand("getsum", conproc);
cmdproc.CommandType = CommandType.StoredProcedure;
cmdproc.Parameters.AddWithValue("@BranchKey", Convert.ToInt32(Session["BranchKey"]));
DateTime dt = Convert.ToDateTime(txtfrom.Text.ToString());
string fromDate = dt.ToShortDateString();
DateTime dt1 = Convert.ToDateTime(txtto.Text.ToString());
string toDate = dt1.ToShortDateString();
cmdproc.Parameters.AddWithValue("@FromDate", SqlDbType.SmallDateTime).Value = fromDate;
cmdproc.Parameters.AddWithValue("@ToDate", SqlDbType.SmallDateTime).Value=toDate;
SqlParameter p1 = cmdproc.Parameters.Add("@tot", SqlDbType.Decimal);
p1.Direction = ParameterDirection.Output;
if ((Convert.ToInt32(cmdproc.ExecuteNonQuery())!= -1) && (cmdproc.Parameters["@tot"].Value)!= DBNull.Value)
{
decimal ot = Convert.ToDecimal(cmdproc.Parameters["@tot"].Value);
if (ot != null)
{
txttotal.Text = ot.ToString();
conproc.Close();
}
}
else
{
clsdataset.ShowAlertMessage("No Data");
txttotal.Text = "";
}
|
|
|
|
|
Are you getting any error? you didn't mentioned that. I guessed one thing, Is your client machine have database? Then Handle the exception using Try..Catch. Reply the details so that we can help you.
|
|
|
|
|
hi,
my client is also having same database with same tables,
client is having data also but displaying no data as a result
|
|
|
|
|
what about the error details? then compare the 2 databases verify those are same.
|
|
|
|
|
I feel executenonquery will return -1 only if it is a procedure
if it is a inline query then it will return the affected rows.
Just check in DB and let me know whether it is updating in tables or not.
|
|
|
|
|
I am developing a web application in ASP.NET using Visual Studio 2008. I am developing it in .NET framework 3.5.
Now is it necessary for the users to have .NET framework 3.5 installed on their systems?
|
|
|
|
|
In the server where you are deploying your ASP.NET application .NET framework 3.5 is required. But for the client which are using your application they only need a web-browser (Like IE, Firefox).
WWW, WCF, WWF, WPF, WFC .... WTF
|
|
|
|
|
Yes! Must be install .Net Framework3.5.
The big boss!
|
|
|
|
|
My vote of 1!
That's an incorrect answer. Client does not need .net framework 3.5 (or any .net framework for that matter) for asp.net application.
The code is processed on the server and the ASP.NET engine produces an equivalent HTML which is rendered to the client. So the client only needs a browser that will display the html (and make http requests to the server).
..Go Green..
|
|
|
|
|
dear sir / madam
how to button click event shows random number between 1 to 9
for example: first click event 4
Second click 5
third click 1
.
.
.
thanks
|
|
|
|
|
idea_007 wrote: how to button click event shows random number between 1 to 9
hat is the problem with doing that ? Did you try anything ?
|
|
|
|
|
You should have done google for this.
You can try something like this.
protected void btnRandomGenerator_Click(object sender, EventArgs e)
{
System.Random RandNum = new System.Random();
lblRandomNumber.Text = RandNum.Next(1, 9).ToString();
}
WWW, WCF, WWF, WPF, WFC .... WTF
|
|
|
|
|
hi iam using asp.net2.o with c#
in my application
when user logins iam storing information in ordders table
OrderNo int primary key (auto increment)
email varchar(50)
and redirects to the orders page.and in this page he will retreive the newly primary key generated and stores in session as orders.
but at the same time another user logins then he is also getting the same orderno . how to handle this situation..
can you correct my code which helps me
protected void Button1_Click(object sender, EventArgs e)
{
int x = 0;
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox c1 = (CheckBox)row.FindControl("chk");
TextBox qt = (TextBox)row.FindControl("txtQuantity");
TextBox tot1 = (TextBox)row.FindControl("txtTotal");
Label categoryname = (Label)row.FindControl("Label1");
Label ItemKey = (Label)row.FindControl("Label2");
Label ItemKeyNameE = (Label)row.FindControl("Label3");
Label CurrentQTY = (Label)row.FindControl("Label4");
Label SalesPrice = (Label)row.FindControl("Label5");
if (c1.Checked == true)
{
int chempty = 0;
SqlCommand getpk = new SqlCommand("select IDENT_CURRENT('TblOrder')", con);
getpk.CommandTimeout = 0;
con.Open();
x = Convert.ToInt32(getpk.ExecuteScalar());
Session["order"] = x;
con.Close();
SqlCommand cmdtemp = new SqlCommand("Addtemp", con);
cmdtemp.CommandType = CommandType.StoredProcedure;
con.Open();
cmdtemp.Parameters.AddWithValue("@OrderNo", Convert.ToInt32(x));
cmdtemp.Parameters.AddWithValue("@CategoryNameE", categoryname.Text);
cmdtemp.Parameters.AddWithValue("@ItemKey", ItemKey.Text);
cmdtemp.Parameters.AddWithValue("@ItemKeyNameE", ItemKeyNameE.Text);
cmdtemp.Parameters.AddWithValue("@CurrentQTY", CurrentQTY.Text);
cmdtemp.Parameters.AddWithValue("@SalesPrice", SalesPrice.Text);
cmdtemp.Parameters.AddWithValue("@Quantity", qt.Text);
cmdtemp.Parameters.AddWithValue("@total", tot1.Text);
chempty = Convert.ToInt32(cmdtemp.ExecuteNonQuery());
con.Close();
}
}
foreach (GridViewRow ro in GridView1.Rows)
{
CheckBox c2 = (CheckBox)ro.FindControl("chk");
TextBox qt1 = (TextBox)ro.FindControl("txtQuantity");
TextBox tot1 = (TextBox)ro.FindControl("txtTotal");
if (c2.Checked)
{
c2.Checked= false;
qt1.Visible = false;
tot1.Visible = false;
}
}
}
|
|
|
|
|
Of course each user is getting the same order number, you are asking for it. Read the documentation for IDENT_CURRENT.
If you want the id for the inserted record return @SCOPE_IDENTIY() from your insert stored procedure.
Also, mixing inline SQL and stored procedures is asking for maintenance headaches. Pick one, preferably stored procs and us it.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
thanks for code project team ....
this logic helps me
|
|
|
|
|
I have some text (shown below) which I want to add to the page. This text contains server side script which I would also like to add dynamically. Is this a possibility?
So far I have attempted to add the text as controls using Page.ParseControl. This successfully adds the controls (textbox and button) to the page but the button events are not working (postback so far looks good).
After researching this further, several possibilities came into play. The first was CodeCompiler and the second was Dynamic Language Extensibility Model (DLEM). I have not read too much into DLEM but the article I read talked mostly about IronPython so this approach may not work in my scenario. In any case, both of these seem like overkill.
I figured before I continue with my research, I would ask for suggestions from the community.
Here are my questions:
1) Are the above possibilities a reasonable approach?
2) Is there something else I should be looking into?
3) Is it even possible to add server side scripts to a page dynamically?
Thanks in advance.
protected override void OnInit(EventArgs e)
{
string formText = @"
<script runat=""server"">
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
((Button)sender).Text = TextBox1.Text;
}
</script>
<asp:TextBox ID=""TextBox1"" runat=""server""></asp:TextBox>
<asp:Button ID=""btn1"" runat=""server"" onclick=""Button1_Click""></asp:Button>
";
Control dControl = Page.ParseControl(formText);
Page.Form.Controls.Add(dControl);
base.OnInit(e);
}
|
|
|
|
|
You can't add the server side script to the page from you code-behind. Think about it, what would be the point? You are already in the code-behind, so just add the controls. You are trying to make it much more complicated than it is.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I want to be able to be able to add scripts AFTER my application has already been compiled. Like VSA. In this example I have added it to my codebehind but the real-life example will not have the string in the code behind.
modified on Sunday, June 20, 2010 10:49 AM
|
|
|
|
|
Why would you? Without a great deal more complexity you can't. There are other ways to accomplish your task I'm sure, why don't you tell us what you want to accomplish and what you think you are gaining by trying to insert code in the manner.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I am trying to create a 'Content Management System' type of app. I want to add 'pages' dynamically with server controls markup and attach them to events.
So bascially, I want to be able to write an entire asp.net page w/ server side scripts in text and execute it at run-time.
What I have been able to accomplish so far is creating the control. However, hooking on to the events is whats causing me problems.
|
|
|
|
|
You do understand that SERVER side scripts are processed on the SERVER? Injecting them in the page on the server is not going to accomplsih anything.
Take a look at other CMS applications such as SharePoint and you will fined they use templates and page level parsers to inject dynamic controls into the output stream.
To add a control and event handler to the page you do something like this.
protected void OnInit(...)
{
Button myBtn = new Button();
myBtn.Text = "Some text";
myBtn.Click += new OnClick;
Page.Controls.Add(myBtn);
}
protected void OnClick(object sender, EventArgs e)
{
...
}
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I understand the server side scripts are executed in the server but I figured that there has to be a point during the life cyle where the markup, including the scripts, are parsed and compiled into dlls. This is where I wanted to inject my text. Seems like I may have to find another solution.
Thanks for your input.
|
|
|
|