|
The problem is ASP.NET is not maintaining viewstate for the controls created runtime. I assume that you are creating columns in page_load . When page_load event raises, ASP.NET had already loaded viewstate for the controls. So to solve your problem, you need to bind your grid before page_load event. Then ASP.NET will maintain viewstate for your dynamic controls. May be PreLoad event.
|
|
|
|
|
Thanks for your reply Navaneeth,
The solution u provided is not working. I am creating the Bound columns at runtime from a method which i am calling in the page_load if the page is not postback. By referring the articles in the google i came to know that i should not be using page_load, instead i should call the method in the initializecomponent() , but since i am working on .Net 2.0 it does not have initializecomponent method.
Thanks
|
|
|
|
|
Anees Mitha wrote: page_load if the page is not postback. By referring the articles in the google i came to know that i should not be using page_load, instead i should call the method in the initializecomponent() ,
Try PreLoad event, This is new to ASP.NET 2.0
|
|
|
|
|
Hi there, are u getting the dat set on page load. if yes than i think this will not create problem.
Also u can try with calling the loadgrid function on page load as well as rowitem command.
better way to create function and call it any where u want and seems creating problem.
this is final solution
Hello Forum
Always be in touch to help about the topic ASP.NET
|
|
|
|
|
Navaneeth, I have tried PreLoad and its not working.
Please find below my sample code so that u get a better idea.
protected void Page_PreLoad(object sender, EventArgs e)
{
if (!IsPostBack)
{ getdata(); }
.....
}
public virtual void grdvwCheckbox_ItemCommand(object s, DataGridCommandEventArgs e)
{
if (e.CommandName == "Select")
{
e.Item.BackColor = System.Drawing.Color.Wheat;
DataGrid dg = (DataGrid) s;
.........
}
}
public void getdata()
{
DataSet ds = new DataSet();
string rptDetails;
rptDetails = txtRptDetails.Text;
GridReports objBO = new GridReports();
ds = (DataSet)objBO.GridData(rptDetails);
grdvwCheckbox.AutoGenerateColumns = false;
foreach (DataColumn c in ds.Tables[0].Columns)
{
grdvwCheckbox.Columns.Add(CreateBoundColumns(c));
}
...................
}
Hope this helps u to help me.
If u have any working sample code in .Net 2.0 where Bound columns are created at runtime and ItemCommand event
is fired then please forward it to me.
Thanks guys for your reply!
|
|
|
|
|
hi friend
iam using telerik ajax manager ajax loadpanel for page loading silently. i have set all property but when its run then javascript error occer
error:-
Microsoft JScript runtime error: Cannot update control with ID: Indexcontrol1_lblSpecify. The control does not exist.
any body tell me what happen
Piyush Vardhan Singh
Programmer
TAS NewDelhi
India
|
|
|
|
|
May be u have put some contentplaceholder or something and changed the name of the control later since controls are named with outercontrols prefixed when used with Masterpages.
Regards
Bino
|
|
|
|
|
Been trying find a way to update a form ( same instance) directly from a class.My example below compiles but the form result leaves the textbox blank. Can anyone help? I'm new to this so go easy on me.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace test1
{
public partial class Form1 : Form
{
public string strStringVarible;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
classtest1 clstest = new classtest1();
clstest.external_class();
}
public void accessor_method()
{
this.textBox1.Text = strStringVarible;
this.textBox1.Refresh();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
________________________________________________________
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms.Design;
using System.Data;
namespace test1
{
class classtest1 : Form1
{
public void external_class()
{
this.strStringVarible = "test123";
this.accessor_method();
}
}
}
|
|
|
|
|
Hi,
classtest1 and Form1 are two different classes and do not represent the same object. You are creating a new instance of classtest1 in classtest1 clstest = new classtest1() . This would automatically create a new object and so any calls to methods in that object will not affect the one it inherits from. This also means that they represent 2 distinct references.
What is happening here is that the textbox of clstest is getting the value test123 but since the form (which is not the same as Form1) is not displayed, you cannot see the change.
A second opinion on that would be nice just to make sure I didn't miss anything
Talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Thank you.
I see what you're saying but all I want to do is update a control and it appears to be more hassle than I anticipated. so how do I reference to the same instance. or am I completely misunderstanding you
|
|
|
|
|
Hardboiled86 wrote: how do I reference to the same instance. or am I completely misunderstanding you
Talal already given the solution to you. I am reiterating, value is assigning to your textbox. But as you inherited form1 in your class, a new object will be created and that is not same where u r textbox relies.
You can rewrite your external_class function like this
public void external_class(Form1 frm)
{
frm.strStringVarible = "test123";
frm.accessor_method();
}
Hardboiled86 wrote: classtest1 clstest = new classtest1();
clstest.external_class();
Rewrite this like
classtest1 clstest = new classtest1();
clstest.external_class(this);
Hope this helps
|
|
|
|
|
Excellent. That makes a lot more sense. Thank you.
|
|
|
|
|
|
I've seen a lot of people on other forums trying to do exactly the same but being given all kinds of wrong answers that don't work. If anyone is googling this, this answer does work. Fact!
|
|
|
|
|
difference between master page and user control
plz let me know
|
|
|
|
|
A master page is a, er, Master Page, and a User Control is a, um, User Control!
Or you could try Google[^] when doing homework...
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
Master Page is used as a content-place-holder so as to make all the pages added inside it as child pages.
Regards
Bino
|
|
|
|
|
Hi all,
I'm using "Directory.delete(folderpath,true)" for deleting a folder containing sub folders and files from server. When i'm trying to delete it, it throws an error saying 'Directory not empty'. All the files and subfolders are getting deleted, but the directory is still there. More over, it removes all the session variables also. How can i fix this issue? Please help.
|
|
|
|
|
Nicejith wrote: it removes all the session variables also.
Is it deleting ASP.NET folders like app_code, app_browser ,bin. Then application will restart and that will end all sessions.
|
|
|
|
|
No.. it deletes a user folder only.
|
|
|
|
|
Hi,
I am creating a web page which contains listbox. Listbox have a paths of file. I want to upload that files on server.
-- modified at 5:34 Friday 3rd August, 2007
|
|
|
|
|
tulsulkar wrote: I am creating a web page which contains listbox. Listbox have a paths of file. I want to upload that files on server.
Impossible until you get HTTPPostedFile object. May be possible with some activex controls.
Reason is, ASP.NET won't be having access to the file paths listed in the listbox. So it can't read files for upload. Instead of this you can use datagrid/gridview. Put a template column contains file upload control. Iterate through all the rows of grid and get fileuploadcontrol object, do the upload.
|
|
|
|
|
Is it in any way possible to use the variable defined and declared in back end C# or VB file and use that variable in corrosponding .aspx file??
If yes please tell me how. I don't want to use session.
|
|
|
|
|
You can't use the session anyhow, but if it was the way to do it, why would you not want to ?
I presume that you mean you want to use it in javascript ? Just add code that outputs the javascript to create a variable with the same value.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi there, according to my understanding about ur question u want to get access Ur variable at C# file to .Aspx file.
For this you need to Define that variable as public and at aspx file you can use that like this
Suppose variable is
public int a=1;
.aspx file code
<%=a%>
Note that you can use any thing defined or property to .aspx file but in tag <%%>
Hello Forum
Always be in touch to help about the topic ASP.NET
|
|
|
|