Hagen
Posts: 16
|
| Posted: 12/04/2007, 5:00 AM |
|
Hi
I'm just an other newbie...
Can anybody please help me with this...
I've created a grid, that collect values from a Access db, and trying to pass an parameter link to query and open an other page based on the date..
The link value is formated as shortdate on the grid..
The problem is that the parameter link for the date, is always generic full date/time format..
( I need to have the date in shortdate format )
Does anyone know how to format a parameter link, or have any other solution ??
The error on the page when wrong formated parameter is used: (in Swedish..)
(DRep.aspx?s_Date=2007-11-01+00%3a00%3a00&...)
[HttpException (0x80004005): Samlingen Controls går inte att justera eftersom kontrollen innehåller kodblock (dvs <% ... %>).]
System.Web.UI.ControlCollection.RemoveAt(Int32 index) +132
Working solution:
(DRep.aspx?s_Date=2007-11-01&...)
Open the selected page correct, and return the values based on the date.
I'm using CSS 3.2, ASP.NET , C# on XP (IIS)
Thanks in advance
// Hagen
|
 |
 |
kevind
Posts: 251
|
| Posted: 12/04/2007, 11:31 AM |
|
you could change the link from a datasource link to an expression and then format the date value the way you want
-OR-
you can use the before show event of the grid on the 'results' page and format the date and store as a session variable and use that in the datasource WHERE parameters instead of a URL value.
kd
_________________
thanks
Kevin
======================
CCS 3.2.x / ASP / MS Access /mySQL / PHP / jQuery / jQuery UI / jQuery Mobile
|
 |
 |
Hagen
Posts: 16
|
| Posted: 12/05/2007, 1:35 AM |
|
Thanks for your answers kevind!
I've tried to change the link from a datasource link to an expression and then format the date with no success...
(- Tried it before also, but I’d give it an other try after your answer)
Grid Name: ‘Grid1’
Link Name: ‘Datum_Link’
Used variable name in expession: ‘Grid1Datum_Link’ - Not quite sure it’s the one for the date to use..
All tries results in that the ‘old’ wrong date with time is still there and a new URL parameter with wrong content as shown below..
I'd tried this as expression:
String.Format( "d",Grid1Datum_Link)
Results in: Results in: ?s_Datum=2007-11-01+00%3a00%3a00& s_Datum=d
String.Format( "{0:yyyy-MM-dd}",Grid1Datum_Link)
Results in: ?s_Datum=2007-11-01+00%3a00%3a00&s_Datum=System.Web.UI.HtmlControls.HtmlAnchor&
String.Format( "->{0,-10}<-",Grid1Datum_Link)
Results in: ?s_Datum=2007-11-01+00%3a00%3a00& s_Datum=-%3eSystem.Web.UI.HtmlControls.HtmlAnchor%3c-
Grid1Datum_Link
Results in: ?s_Datum=2007-11-01+00%3a00%3a00&s_Datum=System.Web.UI.HtmlControls.HtmlAnchor&
String.Format( "->{1,-10}<-",Grid1Datum_Link)
error when result page opens (In Swedish):
[FormatException: Indexet (nollbaserat) måste vara större än eller lika med noll och mindre än storleken på argumentlistan.]
System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args) +1232
System.String.Format(IFormatProvider provider, String format, Object[] args) +65
Translated:
[FormatException: Index (Zero Based) must be >= 0 AND < the size on the argument list.]
I’d also tried to adjust the SQL WHERE statement on the result grid to:
WHERE Datum = Left('{s_Datum}',10)
- To just get the first ten char from the date time parameter passed to it.
But the result page crash when loading when wrong parameter is passed to it..
I’ve yet not tried your other ‘solution’…
I’m even not sure that the variable I’ve used (Grid1DatumLink) is right because of the formatting results..
Perhaps you or someone can give me a hint on how to ??
//Hagen
|
 |
 |
kevind
Posts: 251
|
| Posted: 12/05/2007, 4:27 AM |
|
hi,
you could try this in your expression:
grid.recordset.fields("MyDateField") to reference the data directly
Please check the syntax - i'm a CCS 2.3.x user (upgrading for next project) and it may have changed in the new version.
looking at this again this morning, I recall a similar situation where the date was passed and if I didn't choose the correct /same format in the parameter settings of the target grid, it didn't work properly.
hoping some of this helps.....
kd
_________________
thanks
Kevin
======================
CCS 3.2.x / ASP / MS Access /mySQL / PHP / jQuery / jQuery UI / jQuery Mobile
|
 |
 |
Hagen
Posts: 16
|
| Posted: 12/05/2007, 5:21 AM |
|
Hi,
I searched in the code for where the original parameter was passed..
The code was in the dataprovider.cs file (I’m using C#), and I adjusted the original code:
item.Datum_LinkHrefParameters.Add("s_Datum",System.Web.HttpUtility.UrlEncode(dr["Datum"].ToString()));
To:
item.Datum_LinkHrefParameters.Add("s_Datum",String.Format( "{0:yyyy-MM-dd}",dr["Datum"]));
And it Worked !!! 
But, I’m going to try out your expression solution, and try to format the date string there instead.
- Otherwise, I’m almost sure that my own code will be overwritten by CCS when I’ve forgotten what I’ve done.
So, for now my temporary solution works, But I’ll check out the ‘correct’ way and write back here when I’ve done that..
Thanks again for your help Kevind!!
// Hagen
|
 |
 |
Hagen
Posts: 16
|
| Posted: 12/05/2007, 7:15 AM |
|
I’ve tried to use the grid.recordset.fields("MyDateField") to reference the data directly in the parameter expression:
String.Format( "{0:yyyy-MM-dd}",grid.recordset.fields("Datum"))
But the date time is still passed as full date/time:
?s_Datum=2007-11-13+00%3a00%3a00&
So, I’ll keep my temporary solution a bit longer…
I’ll try to post the code that I’d adjusted again..
- a few chars was lost in my last post,
- (dr is an array with [ i ], in this code I’d to change it to dr[x], otherwise it is lost for some for me not known reason when sending the text..
This time I’ll try to send the whole Code snippet from my DataProvider.cs file:
(The original code is a comment now ‘//’ )
//After execute Select tail @75-C7CB8C70
for(int x=0;x<dr.Count;x++)
{
Grid1Item item=new Grid1Item();
item.HVC_IDNamn.SetValue(dr[x]["HVC_IDNamn"],"");
item.Datum_Link.SetValue(dr[x]["Datum"],"yyyy-MM-dd");
item.Datum_LinkHref = "DygnsRapport.aspx";
//item.Datum_LinkHrefParameters.Add("s_Datum",System.Web.HttpUtility.UrlEncode(dr[x]["Datum"].ToString()));
item.Datum_LinkHrefParameters.Add("s_Datum",String.Format( "{0:yyyy-MM-dd}",dr[x]["Datum"]));
item.Datum_LinkHrefParameters.Add("s_HVC_IDNamn",System.Web.HttpUtility.UrlEncode(dr[x]["HVC_IDNamn"].ToString()));
item.M_V1.SetValue(dr[x]["M_V1"],"");
item.M_V2.SetValue(dr[x]["M_V2"],"");
item.M_V3.SetValue(dr[x]["M_V3"],"");
item.M_V4.SetValue(dr[x]["M_V4"],"");
item.M_V5.SetValue(dr[x]["M_V5"],"");
item.M_V6.SetValue(dr[x]["M_V6"],"");
item.M_V7.SetValue(dr[x]["M_V7"],"");
item.M_V8.SetValue(dr[x]["M_V8"],"");
item.M_V9.SetValue(dr[x]["M_V9"],"");
item.M_V10.SetValue(dr[x]["M_V10"],"");
item.M_V11.SetValue(dr[x]["M_V11"],"");
item.RawData = dr[x];
result[x]=item;
}
_isEmpty = dr.Count == 0;
}
this.mPagesCount = _pagesCount;
return result;
}
//End After execute Select tail
// Hagen
|
 |
 |
kevind
Posts: 251
|
| Posted: 12/05/2007, 11:16 AM |
|
i found this bit of formatting for when i was grouping some records in a grid. don't know if the format might work for you - i've added in a fake URL parameter instead of the label value I was comparing:
CCFormatDate(CCGetParam("MyDate",empty), array("ShortDate"))
just throwing that out there to see if you can play with it to get the URL parameter into the shape you want on the 'receiving' page/grid.
kd
_________________
thanks
Kevin
======================
CCS 3.2.x / ASP / MS Access /mySQL / PHP / jQuery / jQuery UI / jQuery Mobile
|
 |
 |
|