0

I have wizard control with a gridview control, within a gridview I have dropdownlist and label control as a template column. 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

        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

asolmdu
  • 11
  • 2

1 Answers1

0

The first thing you must do is find the wizard control with thin the gridview. You can do this by something like this or:

yourGridViewID.TemplateControl.FindControl("wizardcontrolname")

In your Wizard Control, give the Next Step an ID, this way you can manipulate the wizard step.

In order to manipulate the Next button (actually called Step) you must use the FindControl method within the Wizard Control so you can find the wizard step (displayed as a button with the text as 'Next'), and based on your conditions, enabled or disable it or make it Visible or not visible, depending on the values of the dropdownlist.

Here is some quick code based on the selected item of a dropdownlist, that I wrote quickly:

Protected Sub ddl_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddl.SelectedIndexChanged
    Dim wStep As WizardStep = CType(Wizard1.FindControl("next"), WizardStep)

    If ddl.SelectedValue = 0 Then
        wStep.TemplateControl.Visible = False
        MsgBox("Not Allowed")
    Else
        wStep.Visible = True
    End If
End Sub

It takes a lot of digging through two controls, but it can be done.

Hounddog75
  • 71
  • 6