Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
453 views
in Technique[技术] by (71.8m points)

asp.net - 在gridview控件的下拉列表中检查重复的值(Check for duplicate values within dropdownlist inside gridview control)

I have wizard control with a gridview control, within a gridview I have dropdownlist and label control as a template column.

(我有带有gridview控件的向导控件,在gridview中,我具有下拉列表和标签控件作为模板列。)

I want to check any duplicate values in the dropdownlist, if found, show an error message and don't want to move to the next step in the wizard control.

(我想检查下拉列表中的所有重复值(如果找到),显示错误消息,并且不想转到向导控件中的下一步。)

So far I stored the values in an array and check for duplicate entries and I don't know how to disable the postback on the next button in the wizard control

(到目前为止,我将值存储在数组中,并检查是否有重复的条目,但我不知道如何在向导控件的下一个按钮上禁用回发)

In rowdatabound event

(在rowdatabound事件中)

        foreach (GridViewRow row in GridView1.Rows)
        {
            string s = string.Empty;

            if ((row.FindControl("LCSCD") as Label).Text != "FL")
            {
                if (((DropDownList)row.FindControl("DSBCD")).Visible == false)
                {
                    s = ((Label)row.FindControl("LSBCD")).Text.ToString().Substring(0, ((Label)row.FindControl("LSBCD")).Text.ToString().IndexOf(" "));
                    sarray.Add(s);
                }
                else
                {
                    s = ((DropDownList)row.FindControl("DSBCD")).SelectedItem.Value;
                    sarray.Add(s);
                }
        }

        if (sarray.Distinct().Count() != sarray.Count())
        {

        }
        else
        {

        }

please help me in this regard thanks

(请在这方面帮助我,谢谢)

  ask by asolmdu translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...