You must Sign In to post a response.
  • Category: .NET

    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();
    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";
    grdbatch.DataSource = dt;

    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();
    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>
  • #766448

    This is not the correct way to raise a question, before asking a question please go through the instruction guide.

    Coming back to your question as per my understand the post based on multiple dropdown selection you want to show the result in gridview, right?

    If that is the case why are you using DropDownList Autopostback property to true, my suggestion is remove that AutoPostBack property of dropdown, because it postback the page again, so it is impact to performance, select values to the dropdown and once click on Go button bind the records to GridView.

    Now, On button click event bind your gridview.

    protected void btnGo_Click(object sender, EventArgs e)

    protected void BindGrid()
    DataSet ds=//pass dropdown1, dropdown2, dropdown 3 values as input parameters and fetch data from database.

    If you want to know how to make StoredProcedure for passing input parameters,

    create procedure proc_name
    @ddl1 varchar(100)=null,
    @ddl2 varchar(100)=null,
    @ddl3 varchar(100)=null
    select TextField, ValueField
    from tablename
    where (Col1 = @ddl1 OR @ddl1 IS NULL)
    and (Col2 = @ddl2 OR @ddl2 IS NULL)
    and (Col3 = @ddl3 OR @ddl3 IS NULL)

    Try something like above...

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • Sign In to post your comments