Reputation: 49
I have to show these details in a gridview as Tempname as unique and associated datetime in drodown and the last run by name in a label. Unable to upload the Table picture as i dont have enough reputation.
private void GridLoading() { DataSet ds = new DataSet(); ds = Common.LoadingGrid(); GridView1.DataSource = ds; GridView1.DataBind(); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataSet ds = new DataSet(); Label lblName = e.Row.FindControl("Label1") as Label; ds = Common.RunByDate(lblName.Text); DropDownList ddl = e.Row.FindControl("DropDownList1") as DropDownList; ddl.DataTextField = "RunDate"; ddl.DataValueField = "RunDate"; ddl.DataSource = ds; ddl.DataBind(); var items = ddl.Items; } }
But i am unable to get the Runby name in the label.How can i display it?Below are my stored procedures
Select distinct TempName from SV_JobHistoryTable SELECT TempName,RunDate FROM SV_JobHistoryTable where TempName=@tempname
Upvotes: 0
Views: 179
Reputation: 371
Is this what you want?
SELECT TOP 1
RunByName, RunDate
FROM
SV_JobHistoryTable
WHERE
TempName = @tempname
ORDER BY
RunDate DESC
Or do you want to record more entries than one?
Upvotes: 0
Reputation: 16698
So far what i have understood is, you want to get the Unique TempName
with the Lastest RunDate
, all you need is this query:
SELECT RunByName, MAX(RunDate)
FROM SV_JobHistoryTable
WHERE TempName = @tempname
GROUP BY RunByName
Upvotes: 0
Reputation: 13496
try this:
SELECT TempName,RunDate,max(Runbyname)
FROM SV_JobHistoryTable where TempName=@tempname
group by TempName,RunDate
Upvotes: 0