event PageIndexChanging wasn't handled - events

I'm getting "The GridView 'grdFiles' fired event PageIndexChanging which wasn't handled." even if I've added the event handler:
protected void grdFiles_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GetFiles();
grdFiles.PageIndex = e.NewPageIndex;
grdFiles.DataBind();
}
Any ideas?

Try this code. You need to declare a method on your code behind that handles the PageIndexChanging event.
protected void grdFiles_PageIndexChanging (object sender, GridViewPageEventArgs e)
{
grdFiles.PageIndex = e.NewPageIndex;
bindGridView()
}
the method bindGridView() is
private void bindGridView()
{
grdFiles.DataSource=.....;
grdFiles.DataBind();
}

Related

Is there a way that I can wait for the return of a navigation page and then execute some code after the return?

I have this code:
async void openPage(object sender, EventArgs e)
{
await Navigation.PushAsync(new CFSPage());
// some code here that gets executed only after CFSPage is closed
}
What I would like to do is to only execute the code after the CFS page has returned.
Is there some way that I can do this?
What about using OnDisappearing() in the CFSPage?
You could pass a reference from the pushing page to CFSPage and the react on the disappearing of the pushed page.
async void openPage(object sender, EventArgs e)
{
await Navigation.PushAsync(new CFSPage(this));
}
On CFSPage:
protected override void OnDisappearing()
{
base.OnDisappearing();
this.ActionsOnPushedPageDisappears();
}

C# MySql - data does not appear after insert new data

First of all, I'm new to C# and also programming. So, my situation is after I insert data from a textbox to MySql database, the new data does not appear. FYI, I have the navigation (next previous) button. I have to re-run the apps in order for the new data to be displayed. Here's part of the codes:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//MySql codes to display in textbox
showData(pos);
}
public void showData(int index)
{
txtDisplay.Text = table.Rows[index][0].ToString();
}
private void btnPrevious_Click(object sender, EventArgs e)
{
}
private void btnNext_Click(object sender, EventArgs e)
{
}
private void btnGenNext_Click(object sender, EventArgs e)
{
//codes to generate new data and also insert into db
}
}
Here's my full codes:

Call MarkerClick Method

I wonder how I could able to call MMap_MarkerClick from MMap_InfoWindowClick?
private void MMap_InfoWindowClick(object sender, GoogleMap.InfoWindowClickEventArgs e)
{
//call MMap_MarkerClick
}
private void MMap_MarkerClick(object sender, GoogleMap.MarkerClickEventArgs e)
{
ViewModel.MapMarkerSelected(e.Marker.Title);
}
I am trying to achive it, because MMap_InfoWindowClick does not open new ViewModel, but MMap_MarkerClick does. MarkerClick works but InfoWindowClick does not open ViewModel

Calling button click from another button click

How to press RoutedEventArgs e button (button in page) from EventArgs e button (button on application bar) in windows phone 7
private void button3_Click(object sender, EventArgs e)
{
button0_Click(sender, e);
}
private void button0_Click(object sender, RoutedEventArgs e)
{
}
when i am using above code its giving me
cannot convert from 'System.EventArgs' to 'System.Windows.RoutedEventArgs'
Please Help
SMS CODE:
SmsComposeTask SCT = new SmsComposeTask();
PhoneApplicationService PAS = PhoneApplicationService.Current;
public string SMSNO;
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
object sample;
if (PAS.State.TryGetValue("numbertext", out sample))
SMSNO = sample as string;
if (PAS.State.TryGetValue("messagetext", out sample))
txtOutput.Text = sample as string;
base.OnNavigatedTo(e);
}
private void button2_Click(object sender, RoutedEventArgs e)
{
if (txtOutput.Text != "")
{
SCT.To = SMSNO;
SCT.Body = txtOutput.Text;
SCT.Show();
}
else
{
MessageBox.Show("Output is Empty to send SMS.", "Wait!", MessageBoxButton.OK);
}
}
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
PAS.State["numbertext"] = SMSNO;
PAS.State["messagetext"] = txtOutput.Text;
base.OnNavigatedFrom(e);
}
If you don't use the parameter inside button0_Click, you can just call button0_Click(sender, null); (the reason is that the event from the application bar don't bubble that's why they don't have a RoutedEventArg parameter)

unable to create and event handler for workbook/sheet event in a Addd-in

Im I'm using VS2008 Addin and im trying to write and event handler for a workbook inside the addin but unfortuantly it isn't getting fired can you help
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
FinalWorkbook = ExcelApplication.Workbooks.Add(missing);
FinalWorkbook.SheetActivate +=
new Excel.WorkbookEvents_SheetActivateEventHandler(
FinalWorkbook_ActivateSheet);
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
// MessageBox.Show("The addin has shutdown");
}
public void FinalWorkbook_ActivateSheet(object odjSheet)
{
sheet.BeforeRightClick += Worksheet_BeforeRightClick;
MessageBox.Show(sheet.Name + " Activated2");
}
void Worksheet_BeforeRightClick(Excel.Range Target, ref bool Cancel)
{
Cancel = true;
MessageBox.Show("Right-clicking in this sheet" +
" is not allowed.");
}
}
}
SheetActivate is only fired when you switch between sheets in the workbook, i.e. you click on Sheet2, then Sheet1 and so on.
If you Alt-Tab to a different application and come back to Excel, SheetActivate won't be fired.
You should look at Application.WorkbookActivate, Workbook.Activate or another event.

Resources