如何使用下拉值进行网格视图更多时间显示以使值明显不同 [英] How to Gridview Using Dropdown Value more time Display so that value distinct

查看:58
本文介绍了如何使用下拉值进行网格视图更多时间显示以使值明显不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

My Source Wise Gridview下拉更多时间显示如何解决这个问题,



我的来源是:

My Source Wise Gridview Dropdown More Time Display How to Solve this Problem,

My Source is:

private void LoadAdjustLeave()
    {
        SqlCommand cmd = new SqlCommand();
        SqlDataAdapter da;
        cmd.Connection = con;
        cmd.CommandType = CommandType.Text;
        try
        {
            //string sql = " select USER_ID as UserID, LateDays,Leave,Remainingminutes,Month,Year from Accounts_LateEntry_Salary_Deduct where User_ID='" + gvStaffDetails.SelectedRow.Cells[2].Text.ToString().Trim() + "'";
            string sql = "select convert(VARCHAR(12),LeaveDate) as leavedate, InformType, TotalDays, Leave,Applyhrs from deletetable where UserID='" + gvStaffDetails.SelectedRow.Cells[2].Text.ToString().Trim() + "' and Month='" + Session["paymonth"] + "' and Year='" + Session["payyear"] + "'";
            da = new SqlDataAdapter(sql, con);
            //DataSet ds = new DataSet();
            DataTable dt = new DataTable();
            da.Fill(dt);
            con.Open();
            gvadjustleave.DataSource = dt;
            Session["AdjustLeave"] = dt;
            gvadjustleave.DataBind();
            con.Close();
            
        }
        catch (Exception Ex1)
        {
            LblErr.Text = Ex1.Message.ToString();
            return;
        }
    }







加载时间加载数据多次显示下拉列表,所以我不想要下面的例子。

InformType

没有通知

没有通知

之前
优先

优先

优先

延迟通知

未通知

未通知

未通知

未通知

未通知

未通知

没有通知



所以我不想下拉列表(上图)结果



我想要下拉列表加载下面的数据结果exaple



InformType

之前

延迟通知

没有通知





谢谢




load time Load Data Multiple time Show Dropdown,so i don't want Below Example.
InformType
Not Informed
Not Informed
Prior
Prior
Prior
Prior
Late informed
Not Informed
Not Informed
Not Informed
Not Informed
Not Informed
Not Informed
Not Informed

So I don't want Dropdownlist (above) Result

I want Dropdown List load Data Result below exaple

InformType
Prior
Late informed
Not Informed


Thanks

推荐答案







使用



Item.Clear()在DataBind之前



Ex。

Dropdown => ddlType



Hi,


Use

Item.Clear() Before DataBind

Ex.
Dropdown=> ddlType

ddlType.Item.Clear();
ddlType.DataSource = dt;
ddlType.DataBind();





谢谢



Thanks


如果你想加载将类型保留到下拉列表中,尝试使用下面的sql语句。

if you want to load leave types to drop down list, try with below sql statement.
select distinct InformType from deletetable


这篇关于如何使用下拉值进行网格视图更多时间显示以使值明显不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆