Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Sunday, June 29, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Web Forums - SalesLogix Web Platform & Application Architect
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Web Platform & Application Architect | New ThreadView:  Search:  
 Author  Thread: Hyperlink column for slxgridview (stored procedure)
Andrew Grandin
Posts: 272
 
Hyperlink column for slxgridview (stored procedure)Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jun 10 3:01 AM
Hi All,

I have a gridview populated via a stored procedure (doing this in visual web developer). If i try to define the columns in the grid's properties no data would come through so i checked auto-generate fields and the data comes through fine. However, using this method how would i make one of the columns a hyperlink column? On the other hand im probably not binding the grid properly when trying to define the columns. As it stands the grid populates when i call the following code on formBound():

Sage.Entity.Interfaces.IOpportunity opportunity = (BindingSource.Current as Sage.Entity.Interfaces.IOpportunity);
Sage.Platform.Data.IDataService service = Sage.Platform.Application.ApplicationContext.Current.Services.Get();
string connStr = service.GetConnectionString();

System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connStr);
conn.Open();

System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand("ZSP_ACH_LINKED_ADDRESSES", conn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CreateParameter();
cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("@slx_key", opportunity.Account.Id.ToString()));
System.Data.OleDb.OleDbDataReader reader = cmd.ExecuteReader();
grdLinked.DataSource = reader;
grdLinked.DataBind();
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Hyperlink column for slxgridview (stored procedure)Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jun 10 3:32 AM
ive thought of a possible alternative. The column i wanted hyperlinked contains ID's, when clicked i was hoping to capture the ID to pass to the code executed on the hyperlink click.

If i add a button column as the first column of my gridview (with the text set to "Select"), how could i capture the value in the ID column for the record in the gridview the button field is attached to???
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: Hyperlink column for slxgridview (stored procedure)Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jun 10 6:04 AM
Why cant you use a PageLink column? Just copy the code for an slx one but use your source query for the id/text as opposed to the entity property as an out of the box logix grid would.
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Hyperlink column for slxgridview (stored procedure)Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jun 10 6:24 AM
Hi Nick,

Ive managed to get the gridview populated without autogenerating now (i wasnt binding properly;p) and made the column i want hyperlinked a buttonfield.

How do i capture the value of the button field cell that i click?
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Hyperlink column for slxgridview (stored procedure)Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jun 10 6:25 AM
Hi Nick,

Ive managed to get the gridview populated without autogenerating now (i wasnt binding properly;p) and made the column i want hyperlinked a buttonfield.

How do i capture the value of the button field cell that i click? I can capture the click on the _RowCOmmand event.
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: Hyperlink column for slxgridview (stored procedure)Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jun 10 6:29 AM
Hi Andrew,

Just look one of the events on a standard tab, such as:

protected void QFDataGrid_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Page")
return;
int rowIndex;
if (Int32.TryParse(e.CommandArgument.ToString(), out rowIndex))
{
dsInternalRelationships.SelectedIndex = rowIndex;
object currentEntity = dsInternalRelationships.Current;
if ((currentEntity is Sage.Platform.ComponentModel.ComponentView) && !((Sage.Platform.ComponentModel.ComponentView)currentEntity).IsVirtualComponent)
currentEntity = ((Sage.Platform.ComponentModel.ComponentView)currentEntity).Component;
string id = String.Empty;
//Check if this is an unpersisted entity and use its InstanceId
if (Sage.Platform.WebPortal.PortalUtil.ObjectIsNewEntity(currentEntity))
{
if (QFDataGrid.DataKeys[0].Values.Count > 1) {
foreach (DictionaryEntry val in QFDataGrid.DataKeys[rowIndex].Values)
{
if (val.Key.ToString() == "InstanceId")
{
Guid instanceId = (Guid)val.Value;
dsInternalRelationships.SetCurrentEntityByInstanceId(instanceId);
id = instanceId.ToString();
currentEntity = dsInternalRelationships.Current;
if ((currentEntity is Sage.Platform.ComponentModel.ComponentView) && !((Sage.Platform.ComponentModel.ComponentView)currentEntity).IsVirtualComponent)
currentEntity = ((Sage.Platform.ComponentModel.ComponentView)currentEntity).Component;
}
}
}
}
else
{
foreach (DictionaryEntry val in QFDataGrid.DataKeys[rowIndex].Values)
{
if (val.Key.ToString() != "InstanceId")
{
id = val.Value.ToString();
}
}
}
if (e.CommandName.Equals("Edit"))
{
if (DialogService != null)
{
// QFDataGrid
DialogService.SetSpecs(195, 600, "AddEditInternalRelations", GetLocalResourceObject("fbef65f0-aee9-4ec8-a228-7c4ce3ec59c9.DialogTitleOverride").ToString() );
DialogService.EntityType = typeof(Sage.Entity.Interfaces.IEngagementTeam );
DialogService.EntityID = id;
DialogService.ShowDialog();
}
}
if (e.CommandName.Equals("Delete"))
{
Sage.Entity.Interfaces.IAccount mainentity = this.BindingSource.Current as Sage.Entity.Interfaces.IAccount;
if (mainentity != null)
{
Sage.Entity.Interfaces.IEngagementTeam childEntity = null;
if((currentEntity != null) && (currentEntity is Sage.Entity.Interfaces.IEngagementTeam))
{
childEntity = (Sage.Entity.Interfaces.IEngagementTeam)currentEntity;
}
else if (id != null)
{
childEntity = Sage.Platform.EntityFactory.GetById(id);
}
if(childEntity != null)
{
mainentity.EngagementTeam.Remove(childEntity);
if((childEntity.PersistentState & Sage.Platform.Orm.Interfaces.PersistentState.New) <= 0)
{
childEntity.Delete();
}
dsInternalRelationships.SelectedIndex = -1;
}
}
}
}
QFDataGrid_refresh();
}

See how it looks at e. (this is the event argument of the RowCommand click) to get various properties? Such e.CommandArgument (this is the command argument of the button). It also looks at the DataKeyNames collection to get the Id of the row specified.

Make sure you set the DataKeyNames property of your grid to the database id of the primary key in your source query. The above code does a check for "InstanceId": you wont need an instanceid in yor datakeynames, this is what Logix uses to identify an entity if it hasnt yet been created (such as a one to many on an Insert screen).

Cheers,
Nick
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Hyperlink column for slxgridview (stored procedure)Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jun 10 7:38 AM
Hi Nick,

i tried the following:

int index = Convert.ToInt32(e.CommandArgument);

GridViewRow selectedRow = grdLinked.Rows[index];
TableCell chosenValue = selectedRow.Cells[1];
string value = chosenValue.Text;

DialogService.ShowMessage("clicked: " + value);

But get an error: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Hyperlink column for slxgridview (stored procedure)Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jun 10 9:38 AM
I investigated a little further and it seems as though the gridview is not recognising the fact that it has data in it

when the gridview loads you can see my 1 record in it and all the data items for that record. When i click my button field all i do is message box out gridview.rows.count.toString() which returns 0.

Im guessing this is this why i keep getting the index error? and if so why is it happening? my code is below:

for the gridview:

CellPadding="4" CssClass="datagrid" PagerStyle-CssClass="gridPager"
AlternatingRowStyle-CssClass="rowdk" RowStyle-CssClass="rowlt"
SelectedRowStyle-CssClass="rowSelected" ShowEmptyTable="True" EnableViewState="False"
EmptyTableRowText="<%$ resources:grdLinked.EmptyTableRowText %>"
ExpandableRows="True" ResizableColumns="True" CurrentSortDirection="Ascending"
CurrentSortExpression="" ShowSortIcon="False" UseSLXPagerTemplate="True"
onrowcommand="grdLinked_RowCommand1"
onselectedindexchanged="grdLinked_SelectedIndexChanged"
onrowcreated="grdLinked_RowCreated" AutoGenerateColumns="False"
DataKeyNames="ACNO" >





HeaderText="ACNO" SortExpression="ACNO" />

HeaderText="Company" SortExpression="Company"/>

HeaderText="AC" SortExpression="AC" CommandName="Select" />

HeaderText="Type" SortExpression="Type"/>

HeaderText="Site" SortExpression="Site" />

HeaderText="Address" SortExpression="Address"/>

HeaderText="Line 2" SortExpression="LINE2" />

HeaderText="Town" SortExpression="Town"/>

HeaderText="County" SortExpression="County" />

HeaderText="Postcode" SortExpression="Postcode"/>



<selectedRowStyle CssClass="rowSelected"></selectedRowStyle>




--------------------------------------------------------------------------------------------------------

Binding to stored procedure results:

Sage.Entity.Interfaces.IOpportunity opportunity = (BindingSource.Current as Sage.Entity.Interfaces.IOpportunity);

Sage.Platform.Data.IDataService service = Sage.Platform.Application.ApplicationContext.Current.Services.Get();
string connStr = service.GetConnectionString();

System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connStr);
conn.Open();

System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand("ZSP_ACH_LINKED_ADDRESSES", conn);
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CreateParameter();
cmd.Parameters.Add(new System.Data.OleDb.OleDbParameter("@slx_key", opportunity.Account.Id.ToString()));

System.Data.OleDb.OleDbDataReader reader = cmd.ExecuteReader();
grdLinked.DataSource = reader;
grdLinked.DataBind();




[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Hyperlink column for slxgridview (stored procedure)Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jun 10 9:41 AM
sorry all the code did not paste properly but hopefully you get the idea:

im missing the lines (asp:ButtonField DataTextField="AC") etc......

All columns are boundfields except for the one button field.
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: Hyperlink column for slxgridview (stored procedure)Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jun 10 9:47 AM
OK that doesnt really surprise me SLX gridviews. For some reason they turn the viewstate off and rebind every postback (In OnFormBound). Set EnableViewState to true in the grid and only bind it OnActivating (override). If viewstate is switched off you can only get at the values of the grid when the rebind occurs - this is obviously happening AFTER your code is firing.

You will have to reset the Page_Changing and Sorting events (currently they just cause a postback and the OnFormBound/RowCommand takes care of it) - but we can go over that shortly, just see if that works for your current issue first.
[Reply][Quote]
Andrew Grandin
Posts: 272
 
Re: Hyperlink column for slxgridview (stored procedure)Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jun 10 9:56 AM
I.....cant.....believe.....it!!! I set EnableViewState to true and i can now access the selected value in the cell!

Amazing how something so simple can bring 6 and a half hours of HELL to an end!!!!!!!

P.S do you have a 24 hour support telephone number so i can access you away from this forum
[Reply][Quote]
Nick Hollis
Posts: 549
Top 10 forum poster: 549 posts
 
Re: Hyperlink column for slxgridview (stored procedure)Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Jun 10 10:04 AM
I do have 24 hour support line, its called slxdeveloper , but I do disappear for a few weeks every so often!

Remember on your paging events you will need to rebind your grid and set the PageIndex, something like:

protected void grdXXpage_changing(object sender, GridViewPageEventArgs e)
{
string userId = string.Empty;
userId = Sage.Platform.Application.ApplicationContext.Current.Services.Get(true).UserId.Trim();

Sage.Platform.Data.IDataService service = Sage.Platform.Application.ApplicationContext.Current.Services.Get();
string constr = service.GetConnectionString();
SqlDataSource SqlMissingRequiredFields = new SqlDataSource();
SqlMissingRequiredFields.ConnectionString = constr;
SqlMissingRequiredFields.DataSourceMode = SqlDataSourceMode.DataSet;
SqlMissingRequiredFields.ProviderName = "System.Data.OleDb";


SqlMissingRequiredFields.SelectCommand = "SELECT * FROM XX_XX_XXWHERE USERID = '" + userId + "' AND XX = 'T'";
grdXX.DataSource = SqlMissingRequiredFields;
grdXX.PageIndex = e.NewPageIndex;
grdXX.DataBind();
}

(notice the PageIndex = e.NewPageIndex....)

And there's some code to boot to bind a grid to a nice and simple SQLDATASOURCE!

[Reply][Quote]
Matt
Posts: 2
 
Re: Hyperlink column for slxgridview (stored procedure)Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Jul 10 11:56 AM
Would you mind posting what you ended up coding? I'm having that exact same problem.

I have the grid bound from an external source and need to have a hyperlink with one of the fields in the table as a parameter.

I just don't know how to access the actual fields in the table.

Thanks,
Matt

Edit: I found where you were talking about by changing the girdviews "enable view state" property in the actual form, but I am having problems doing this programmatically.
There is no enable view state property for a the standard grid. You are able to edit the view state if you cast it into a slxgrid view, but then it does not appear to work when you change it. Any suggestions?
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 6/29/2025 11:58:35 PM