Calling a databind method on a webform in a ascx file

G

Guest

Hey everyone. I was wondering if someone could help me with a small problem.
I have designed a user control and I would have inserted it on a aspz page
(WebForm1). The User control is being used to help with the navigation
through a datagrid. The control handles all the paging issues and on the
webform I do all the DataBinding.

My problem is that at the end of code of an on-click event for a link button
on my user control (DataGridNavigation.ascx) I need to call the DataBind
Method. The problem is that the DataBind method is sitting on the WebForm1
code behind page.

Here is a part of my code on the Code behind in the user control (ascx.cs
file) and commented is here I need to call the DataBind method.

private void No1_Click(object sender, System.EventArgs e)
{
_currentPageNumber = int.Parse(No1.Text);
this.CurrentPage.Text = _currentPageNumber.ToString();
ShowHideNavigation();
/*Need to call the DataBind method in here somehow
This DataBind Method is sitting on the WebForm1 code behind page*/
}

I would be very grateful if someone could help me please.
 
G

Guest

Stephen:

I have not done a lot of C#, but I know that you can setup a public
property in your user control. That public property would hold a reference
to the datagrid on the main webform. Inside of WebForm1 assign a reference
to the datagrid to the public property of your user control. You will have
to declare your user control as a protected withevents variable in the
WebForm1.aspx. The name of the user control variable will have to match the
ID assigned to the user control in the WebForm.aspx page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top