Recently, I encountered a problem when passing values on the page. The problem is restored:
The first page uses the data source control DataBindControl to bind the data source, and then uses the HyperLinkField control to bind the background data. , and pass parameters to the second page. The data binding code is as follows:
<span style="font-size:18px;"><SOA:DeluxeObjectDataSourcerunat="server" EnablePaging="True"ID="DataSourceServicePack" TypeName="SinoOcean.Seagull2.TransactionData.PlanManage.ReportHelper.GenerrateKeyPointAchievingRateOfServicepack()"/>页面传值代码如下:<asp:HyperLinkFieldDataNavigateUrlFields="PlanCode,PlanVersionStartTime,beginTime,endTime"DataNavigateUrlFormatString="DelayKeyPointTaskOfServicePack.aspx?PlanCode={0}&PlanVersionStartTime={1}&beginTime={2}&endTime={3}" Target="_blank" Text="查看" HeaderText="查看"/></span>
The problem occurred. After running the code, I found that on the page The hyperlink button is in a non-clickable state. Analysis found that this button is available after deleting the time parameter. So why is this the case? According to Baidu, it turned out to be a time format problem. When binding the data source, the time format of the data source was "yyyy-MM-dd HH:mm:ss.fff". Du Niang said that the address bar cannot recognize special symbols, so, This link is not clickable.
Since the format is not correct, just change it. Wouldn’t it be enough to change it to one that can be passed on? I started immediately, tried it, and changed it to "yyyy/MM/dd HH/mm/ss.fff". Sure enough, it could be transferred. The value transfer problem was solved, but a new problem appeared again.
After the data is transferred successfully, it still cannot be queried normally. It is found that normal data query cannot be performed after changing the format. It turns out that the format is still wrong, so what should I do? Change it back on the new page.
Continuing on Baidu, I found a solution, which is the string segmentation and conversion method. First, split the string into multiple parts, and then convert them separately.
My string is divided into two parts. The first part needs to convert the special characters in the middle of the date into horizontal short lines. The second part needs to convert the special characters into colons. The conversion methods are different, so convert them separately. .
When transferring values on the page, redesign the string transfer format to "yyyy/MM/dd THH/mm/ss.fff" format, and then divide it into two strings according to T as the delimiter. Convert separately, the code is as follows.
<span style="font-size:18px;">stringversionStartTime =WebUtility.GetRequestQueryString("PlanVersionStartTime",""); if (versionStartTime !="") { string ss =versionStartTime.Split('T')[0].ToString(); string ee =versionStartTime.Split('T')[1].ToString(); versionStartTime =ss.Replace('/', '-') + " " + ee.Replace('/', ':'); }</span>
The data is converted successfully and can be queried normally.