Displaying all the users in the batch when i select all from drop down list
public void Bindgrid(){
lblerrmsg.Text = "";
string query = "select Mts.LineCount,Mts.AudioID,Mts.ReviewStatus,convert(varchar(10), mts.CreatedDate,101) as CreatedDate,u.UserID,si.AuditoName from MTWorkStatus Mts,users u,subjectItems si where " +
"u.BatchName='" + ddlbatchname.SelectedValue + "' and u.empid='" + ddluser.SelectedValue + "' and mts.TraineeID=u.Empid and si.ID= Mts.AudioID";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
dt.Columns.Add("HyperLink", typeof(string));
// dtfill.Columns.Add("httppath", typeof(string));
foreach (DataRow row in dt.Rows)
{
row["HyperLink"] = "NOT DONE";
}
for (int i = 0; i <= dt.Rows.Count - 1; i++)
{
string ReviewStatus = dt.Rows[i]["ReviewStatus"].ToString();
if (ReviewStatus == "True")
{
dt.Rows[i]["HyperLink"] = "DONE";
}
}
dt.AcceptChanges();
grdbatch.DataSource = dt;
grdbatch.DataBind();
}
protected void grdbatch_RowDataBound(object sender, GridViewRowEventArgs e)
{
foreach (TableCell tc in e.Row.Cells)
{
tc.BorderStyle = BorderStyle.None;
tc.BorderWidth = 0;
tc.BorderColor = System.Drawing.Color.Transparent;
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblID = (Label)e.Row.FindControl("lblID");
string qry = "SELECT m.AudioID, m.Completed,m.ReviewStatus FROM MTWorkStatus m , SubjectItems s where m.Completed='True' and m.ReviewStatus='True' and m.cretedby='" + ddluser.SelectedItem.Text + "'";
SqlCommand cmd = new SqlCommand(qry, con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
string status = dt.Rows[i]["ReviewStatus"].ToString();
if (lblID.Text == status)
{
e.Row.BackColor = System.Drawing.Color.LightGray;
e.Row.Enabled = false;
e.Row.ToolTip = "This Record is Completed";
}
}
}
}
This is the method which displays the records that are done and not done i gird view now i had added a drop down with done and not done when user selects done only the records which are done should be displayed in grid and if he selects not done the records that are not done should be displayed how can i do this
<asp:DropDownList ID="ddlstatus" runat="server" AutoPostBack="true" Width="120px" style="margin-left: 5px" OnSelectedIndexChanged="ddlstatus_SelectedIndexChanged" >
<asp:ListItem Value="0">--Select--</asp:ListItem>
<asp:ListItem Value="1">Done</asp:ListItem>
<asp:ListItem Value="2">Not Done</asp:ListItem>
</asp:DropDownList>