Iron Speed Technical Forums
Sign up Latest Topics
 
 
 


Reply
  Author   Comment  
dozero

Registered:
Posts: 13
Reply with quote  #1 
I have created a basic show records page.  If there are no records, it displays nothing as expected.  I would like to display a message and a button that says "new record" instead of displaying nothing.

I am not sure how to go about doing this.  I am removing the default add record button from the actions button so the end user will not be able to use that.
timt

Avatar / Picture

Iron Speed MVP
Registered:
Posts: 556
Reply with quote  #2 
Hi

You can write a little custom code to check the record count and if 0 then show you own button.

1. Create a button and add to the table control (why not use the existing add button?).

2. In your code behind after the page has loaded ie   

public void LoadData()
{
  LoadData_Base();
  if( MyTableRecordControl.TotalRecords == 0 )
  {
      MyAddbutton.Visible = true;
      // add any comment to a label as well if needed
  }
  else
  {
     MyAddbutton.Visible = false;
  }
}
HTH

__________________
Tim Titchmarsh Iron Speed Consultant MVP
London UK based
+44 (0)1621 835002
http://www.lightspeeditsolutions.co.uk/dotnetarchitect
timt@dotnetarchitect.co.uk
timt@lsits.co.uk
dozero

Registered:
Posts: 13
Reply with quote  #3 

Perfect, that's what I needed.  My code is vb.net, here is what I ended up with:

Public Sub LoadData()

LoadData_Base()

 If (ACM2013TableControl.TotalRecords=0) Then
   NewProfileButton.Visible = TRUE
 Else
   NewProfileButton.Visible = FALSE
 End If

End Sub



mprindiville

Registered:
Posts: 22
Reply with quote  #4 
Is there a way to do something similar to this except instead of a value of 0.  Is is based on a field value(literal) like status = yes. 
JimiJ

Avatar / Picture

MVP Developer
Registered:
Posts: 1,966
Reply with quote  #5 
Yes, that can be done. Try this:

If (LiteralControlName.Text.Equals("Yes")) Then
NewProfileButton.Visible = TRUE
Else
NewProfileButton.Visible = FALSE
End If

Cheers,
Jimi J


__________________

  Jaime Jegonia
[jts_logo]

Iron Speed MVP Developer
 

". . . and whoever sows generously will also reap generously" 2 Cor 9:6

achile711

Registered:
Posts: 19
Reply with quote  #6 
Hi,
how to make button visble or not based on Etat cell as shown on the example :
For example i am not allowed to delete row if Etat = Validé allow.jpg 



JimiJ

Avatar / Picture

MVP Developer
Registered:
Posts: 1,966
Reply with quote  #7 

You can place this code piece @ ControlRow PreRender Event:

C#
if Etat.Text.Equals("Validé")
{
DeleteRowButton.Visible = false;
}
else DeleteRowButton.Visible = true;

VB
If Etat.Text.Equals("Validé") Then
DeleteRowButton.Visible = False
Else
DeleteRowButton.Visible = True
End If

Jimi J


__________________

  Jaime Jegonia
[jts_logo]

Iron Speed MVP Developer
 

". . . and whoever sows generously will also reap generously" 2 Cor 9:6

achile711

Registered:
Posts: 19
Reply with quote  #8 

Thank you 
But i have this error :

4.jpg Can you help me :
this my code :

private void RecordControl_PreRender(object sender, EventArgs e)
{
if (this.Etat.Text.equals("Validé"))
{

this.Gestion_Des_ArchivesRowEditButton.Visible = false;
}
else
{
this.Gestion_Des_ArchivesRowEditButton.Visible = true;
}
}

Thank you 






JimiJ

Avatar / Picture

MVP Developer
Registered:
Posts: 1,966
Reply with quote  #9 
Try Equals (not equals).
__________________

  Jaime Jegonia
[jts_logo]

Iron Speed MVP Developer
 

". . . and whoever sows generously will also reap generously" 2 Cor 9:6

achile711

Registered:
Posts: 19
Reply with quote  #10 
I did it but i have the same problem.
JimiJ

Avatar / Picture

MVP Developer
Registered:
Posts: 1,966
Reply with quote  #11 
Probably, "Equals" is not available in V9. You may try then:
if (this.Etat.Text == "Validé")


Cheers,
Jimi J 



 

__________________

  Jaime Jegonia
[jts_logo]

Iron Speed MVP Developer
 

". . . and whoever sows generously will also reap generously" 2 Cor 9:6

achile711

Registered:
Posts: 19
Reply with quote  #12 
the same problem.

this is my code in vb :

Public Class ArchiveTableControlRow
Inherits BaseArchiveTableControlRow
Protected Sub MyPreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender

if me.Etat.Text = ("Validé") then
me.ArchiveRowDeleteButton.Visible = False

Else
me.ArchiveRowDeleteButton.Visible = true
end if
end sub

JimiJ

Avatar / Picture

MVP Developer
Registered:
Posts: 1,966
Reply with quote  #13 
Please translate the Error into English and post.

Also why you need to enclose "Validé" with ()?


__________________

  Jaime Jegonia
[jts_logo]

Iron Speed MVP Developer
 

". . . and whoever sows generously will also reap generously" 2 Cor 9:6

achile711

Registered:
Posts: 19
Reply with quote  #14 
the same problem.

Public Class ArchiveTableControlRow
Inherits BaseArchiveTableControlRow
Protected Sub MyPreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender

if me.Etat.Text = "Validé" then
me.ArchiveRowDeleteButton.Visible = False

Else
me.ArchiveRowDeleteButton.Visible = true
end if
end sub

Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.

Download Iron Speed Designer

Terms of Service Privacy Statement