データベースからのデータで満たされた GridView があります。mssql 関数を使用してデータを取得します。これは私が自分のデータを取得する方法です:
private void GetNoLocationScanAddress(GridView grid, int week)
{
try
{
FunctionDataContext function = new FunctionDataContext();
List<Fn_GetNoLocationAddressGroupedResult> address = function.Fn_GetNoLocationAddressGrouped("0X", week).ToList();
grid.DataSource = address;
grid.DataBind();
}
catch (Exception exception)
{
Console.WriteLine("ERROR in GetNoLocationScanAddress() method. Error Message : " + exception.Message);
}
}
問題は、関数内のデータを既に並べ替えていることです。また、Switch ケースを使用して、表示用に選択されたデータを判別しています。
protected void WeekSelector_OnIndexChanhed(object sender, EventArgs e)
{
switch (RadioButtonList.SelectedIndex)
{
case 0:
GetScanErrorsAddress(Grid, Convert.ToInt32(WeekSelector.SelectedValue));
Grid.DataBind();
break;
case 1:
GetScanErros(Grid, Convert.ToInt32(WeekSelector.SelectedValue));
Grid.DataBind();
break;
case 2:
GetNoLocationScanAddress(Grid, Convert.ToInt32(WeekSelector.SelectedValue));
Grid.DataBind();
break;
case 3:
GetNoLocationScan(Grid, Convert.ToInt32(WeekSelector.SelectedValue));
Grid.DataBind();
break;
}
}
関数 SQL:
SELECT TOP (100) PERCENT Request1.RequestID, TrackIT.dbo.Sending.Barcode, TrackIT.dbo.Address_View.AdrID, TrackIT.dbo.Address_View.Name,
TrackIT.dbo.Address_View.Street, TrackIT.dbo.Address_View.HouseNo, TrackIT.dbo.Address_View.Postal, TrackIT.dbo.Address_View.City,
TrackIT.dbo.Address_View.Country, Request1.Latitude +','+ Request1.Longitude AS Location, Case when(Request1.Latitude<>'')then cast(1 as bit) else cast(0 as bit) end AS showLocation, Request1.ReceivedDate
FROM (SELECT DISTINCT RequestID, LTRIM([Content]) AS Barcode, Latitude, Longitude, ReceivedDate
FROM dbo.RequestWithLocation
WHERE (Site LIKE @Site) AND ([Content] <> '') AND (AddressID = '0') AND (ReceivedDate > DATEADD(day, -@ReceivedDate, GETDATE()))) AS Request1 INNER JOIN
TrackIT.dbo.Sending ON Request1.Barcode = TrackIT.dbo.Sending.Barcode INNER JOIN
TrackIT.dbo.Address_View ON TrackIT.dbo.Sending.DeliveryAdrID = TrackIT.dbo.Address_View.AdrID
ORDER BY TrackIT.dbo.Address_View.AdrID
誰でもこれで私を助けることができますか?