473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

user control

I'm using this code to check click event on usercontrol.
But I get an error:
User Control:(GridFilter)
public delegate void FilterText(string filterText);

public event FilterText textFilter;

private void buttonTrazi_Click(object sender, EventArgs e)

{

if (textFilter != null)

textFilter(txtFilter.Text);

}

Main form:

private void Main_Load(object sender, EventArgs e)

{

GridFilter.textFilter += new Utils.GridFilter.FilterText(gridFilter);

}

protected void gridFilter(string filter)

{

string tree = treeKolekcija.SelectedNode.Text;
switch (tree)

{

case "Akcioni":

DataRow[] afrows = db.dataSetKolekcija.Akcioni.Select("Naziv LIKE '" +
filter + "%'" );

DataTable newtable = new DataTable();

int c = 0;

foreach (object o in afrows[0].ItemArray)

{

newtable.Columns.Add(new DataColumn(string.Format("col{0}", c++),
o.GetType()));

}

foreach (DataRow dr in afrows)

{

newtable.Rows.Add(dr.ItemArray);

}

gridData.Grid.DataSource = newtable;
break;

}

}
Apr 18 '07 #1
7 3037
You haven't assigned the Button Click event handler to the handler method
you created.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Hrvoje Voda" <hr*********@luatech.comwrote in message
news:f0**********@ss408.t-com.hr...
I'm using this code to check click event on usercontrol.
But I get an error:
User Control:(GridFilter)
public delegate void FilterText(string filterText);

public event FilterText textFilter;

private void buttonTrazi_Click(object sender, EventArgs e)

{

if (textFilter != null)

textFilter(txtFilter.Text);

}

Main form:

private void Main_Load(object sender, EventArgs e)

{

GridFilter.textFilter += new Utils.GridFilter.FilterText(gridFilter);

}

protected void gridFilter(string filter)

{

string tree = treeKolekcija.SelectedNode.Text;
switch (tree)

{

case "Akcioni":

DataRow[] afrows = db.dataSetKolekcija.Akcioni.Select("Naziv LIKE '" +
filter + "%'" );

DataTable newtable = new DataTable();

int c = 0;

foreach (object o in afrows[0].ItemArray)

{

newtable.Columns.Add(new DataColumn(string.Format("col{0}", c++),
o.GetType()));

}

foreach (DataRow dr in afrows)

{

newtable.Rows.Add(dr.ItemArray);

}

gridData.Grid.DataSource = newtable;
break;

}

}


Apr 18 '07 #2
I don't understand.
I have an event textFilter that I check in button_click event.

"Kevin Spencer" <un**********@nothinks.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
You haven't assigned the Button Click event handler to the handler method
you created.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Hrvoje Voda" <hr*********@luatech.comwrote in message
news:f0**********@ss408.t-com.hr...
>I'm using this code to check click event on usercontrol.
But I get an error:
User Control:(GridFilter)
public delegate void FilterText(string filterText);

public event FilterText textFilter;

private void buttonTrazi_Click(object sender, EventArgs e)

{

if (textFilter != null)

textFilter(txtFilter.Text);

}

Main form:

private void Main_Load(object sender, EventArgs e)

{

GridFilter.textFilter += new Utils.GridFilter.FilterText(gridFilter);

}

protected void gridFilter(string filter)

{

string tree = treeKolekcija.SelectedNode.Text;
switch (tree)

{

case "Akcioni":

DataRow[] afrows = db.dataSetKolekcija.Akcioni.Select("Naziv LIKE '" +
filter + "%'" );

DataTable newtable = new DataTable();

int c = 0;

foreach (object o in afrows[0].ItemArray)

{

newtable.Columns.Add(new DataColumn(string.Format("col{0}", c++),
o.GetType()));

}

foreach (DataRow dr in afrows)

{

newtable.Rows.Add(dr.ItemArray);

}

gridData.Grid.DataSource = newtable;
break;

}

}



Apr 18 '07 #3
You created a Button click event Handler method, but you didn't assign it to
the Button's Click event. You need to do something like the following:

buttonTrazi.Click += new EventHandler(buttonTrazi_Click);

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Hrvoje Voda" <hr*********@luatech.comwrote in message
news:f0**********@ss408.t-com.hr...
>I don't understand.
I have an event textFilter that I check in button_click event.

"Kevin Spencer" <un**********@nothinks.comwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>You haven't assigned the Button Click event handler to the handler method
you created.

--
HTH,

Kevin Spencer
Microsoft MVP

Printing Components, Email Components,
FTP Client Classes, Enhanced Data Controls, much more.
DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

"Hrvoje Voda" <hr*********@luatech.comwrote in message
news:f0**********@ss408.t-com.hr...
>>I'm using this code to check click event on usercontrol.
But I get an error:
User Control:(GridFilter)
public delegate void FilterText(string filterText);

public event FilterText textFilter;

private void buttonTrazi_Click(object sender, EventArgs e)

{

if (textFilter != null)

textFilter(txtFilter.Text);

}

Main form:

private void Main_Load(object sender, EventArgs e)

{

GridFilter.textFilter += new Utils.GridFilter.FilterText(gridFilter);

}

protected void gridFilter(string filter)

{

string tree = treeKolekcija.SelectedNode.Text;
switch (tree)

{

case "Akcioni":

DataRow[] afrows = db.dataSetKolekcija.Akcioni.Select("Naziv LIKE '" +
filter + "%'" );

DataTable newtable = new DataTable();

int c = 0;

foreach (object o in afrows[0].ItemArray)

{

newtable.Columns.Add(new DataColumn(string.Format("col{0}", c++),
o.GetType()));

}

foreach (DataRow dr in afrows)

{

newtable.Rows.Add(dr.ItemArray);

}

gridData.Grid.DataSource = newtable;
break;

}

}




Apr 18 '07 #4
On Wed, 18 Apr 2007 03:12:41 -0700, Hrvoje Voda <hr*********@luatech.com>
wrote:
I'm using this code to check click event on usercontrol.
But I get an error:
What error do you get? Where does the error happen?
Apr 18 '07 #5
I get an error on main form.

error : An object reference is required for the nonstatic field, method, or
property 'Utils.GridFilter.textFilter'
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Wed, 18 Apr 2007 03:12:41 -0700, Hrvoje Voda <hr*********@luatech.com>
wrote:
>I'm using this code to check click event on usercontrol.
But I get an error:

What error do you get? Where does the error happen?

Apr 18 '07 #6
On Wed, 18 Apr 2007 13:10:31 -0700, Hrvoje <hr**********@zg.htnet.hr>
wrote:
I get an error on main form.

error : An object reference is required for the nonstatic field, method,
or property 'Utils.GridFilter.textFilter'
"On main form" is not very useful information. Where specifically does
your error happen? What causes it to happen?

Not that you should at this point really need our help. It seems to me
that the error is pretty self-explanatory. Somewhere you are using
"Utils.GridFilter.textFilter" and it requires an object reference even
though you are not providing one. You should be able to figure that one
out. If not, you really need to provide actual information that describes
the context of the error for us.

Pete
Apr 18 '07 #7
it worked fine on another control.
Now, I put it on a different control and it doesn't work.
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Wed, 18 Apr 2007 13:10:31 -0700, Hrvoje <hr**********@zg.htnet.hr>
wrote:
>I get an error on main form.

error : An object reference is required for the nonstatic field, method,
or property 'Utils.GridFilter.textFilter'

"On main form" is not very useful information. Where specifically does
your error happen? What causes it to happen?

Not that you should at this point really need our help. It seems to me
that the error is pretty self-explanatory. Somewhere you are using
"Utils.GridFilter.textFilter" and it requires an object reference even
though you are not providing one. You should be able to figure that one
out. If not, you really need to provide actual information that describes
the context of the error for us.

Pete

Apr 19 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
4
by: louise raisbeck | last post by:
Resending this as own topic as didnt get answer from original. Would be grateful for a response from anyone that knows. Thanks. Hi there, I found your post really helpful..but i wondered if, once...
0
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
0
by: davidr | last post by:
Hi, I have a panel that I load user Control in no problem. The problem arrises when I do a post back on one of these user controls. I have button it does a click event. In this click event I...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
3
by: Fred Chateau | last post by:
I am trying to access a user control class, for a user control that is loaded dynamically, from the containing page. I have been able to access Web controls in the user control, but so far I have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.