I am displaying different gridview based on selected row in gridview.
Protected void Bindgrid1()
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[5] { new DataColumn("Date"), new DataColumn("Location"), new DataColumn("TimeIn"), new DataColumn("TimeOut"), new DataColumn("Hours") });
dt.Rows.Add("1-01-2018", "Chennai", "9.30", "6.30", "9");
dt.Rows.Add("2-01-2018", "Chennai", "9.30", "7.30", "10");
dt.Rows.Add("3-01-2018", "Chennai", "9.30", "5.30", "8");
dt.Rows.Add("4-01-2018", "Chennai", "9.30", "8.00", "10.30");
dt.Rows.Add("5-01-2018", "Chennai", "9.30", "7.00", "9.30");
GridView1.DataSource = dt;
GridView1.DataBind();
}
Protected void Bindgrid2()
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[5] { new DataColumn("Date"), new
DataColumn("Location"), new DataColumn("TimeIn"), new DataColumn("TimeOut"),
new DataColumn("Hours") });
dt.Rows.Add("8-01-2018", "Chennai", "9.30", "7.00", "9.30");
dt.Rows.Add("9-01-2018", "Chennai ", "10.30", "7.30", "9");
dt.Rows.Add("10-01-2018", "Chennai", "11.30", "5.30", "6");
dt.Rows.Add("11-01-2018", "Chennai", "10.00", "8.00", "10.00");
dt.Rows.Add("12-01-2018", "Chennai", "9.00", "7.00", "10.00");
GridView2.DataSource = dt;
GridView2.DataBind();
}
In run mode as follows
Date Location Timein TimeOut Workinghours ViewAttendance
1/1/2018 Chennai 9.30 6.30 9 Clickhere
2//12018 Chennai 9.30 7.30 10 Clickhere
3/1/2018 Chennai 9.30 5.30 8 Clickhere
4/1/2018 Chennai 9.30 8.00 10.30 Clickhere
5/1/2018 Chennai 9.30 7.00 9.30 Clickhere
in the run mode when i click the first row in gridview i want to visible the Gridview1.
Simliarily when i click the second row in gridview i want to visble the Gridview2.
for selecting gridview based on each row i written a code as follows
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string username = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Date"));
LinkButton lnkbtnresult = (LinkButton)e.Row.FindControl("lnkdelete");
BindGrid1();
Gridview1.visible = true;
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
string username = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "Location"));
LinkButton lnkbtnresult = (LinkButton)e.Row.FindControl("lnkdelete");
BindGrid2();
Gridview2.visible = true;
}
}
But when i click the second row in gridview, it shows the gridview1 only, i want to visible the gridview2.
from my above code what is the mistake.
What I have tried:
See above