Как избежать публикации обратно в сетке - PullRequest
0 голосов
/ 10 апреля 2019

Я использую файл класса, чтобы связать выпадающий список в gridview. Я добавляю каждую строку кнопкой изображения, после чего я выбираю выпадающий список, кнопка изображения не будет работать, в конце концов, у меня есть панель обновления с ajax ToolkitScriptManager.При использовании EventValidation кнопка false работает, выбранные значения раскрывающегося списка исчезают.

<ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"/>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>

<asp:GridView  ID="travel_grid"  runat="server" OnRowDataBound="travel_grid_RowDataBound" OnRowDeleting="travel_grid_RowDeleting" >
<Columns>
<asp:TemplateField>
<FooterTemplate>

<asp:Label ID="Label43" runat="server"></asp:Label>
<asp:ImageButton ID="ButtonAdd" runat="server" BorderStyle="None"ImageUrl="~/images/addbutton.png"  OnClick="ButtonAdd_Click1" />
</FooterTemplate>

<ItemTemplate> 
  <asp:DropDownList ID="ddlContinent" runat="server" ></asp:DropDownList>
<ajax:CascadingDropDown ID="ContinentCascading" runat="server" Category="Continent" TargetControlID="ddlContinent" LoadingText="Loading Continent..." PromptText="Select Continent" ServiceMethod="BindContinentdropdown" ServicePath="DropdownWebService.asmx">
</ajax:CascadingDropDown>

  </ItemTemplate>
 </asp:TemplateField>

<asp:CommandField ButtonType="Image" DeleteImageUrl="~/images/delete.png" ItemStyle-CssClass="delete-btn" ShowDeleteButton="True">
 </asp:CommandField>
</Columns>
<EmptyDataRowStyle />
 </asp:GridView>

Dropdownwebservice.cs

 public CascadingDropDownNameValue[] BindContinentdropdown(string knownCategoryValues, string category)

    {

 List<CascadingDropDownNameValue> continentdetails = new List<CascadingDropDownNameValue>();

        try
        {


                MySqlConnection concontinent = new MySqlConnection(connection);
                concontinent.Open();
                string cmdcountry = "select * from continent";
                MySqlDataAdapter dacontinent = new MySqlDataAdapter(cmdcountry, connection);
                MySqlCommand MyCommand = new MySqlCommand(cmdcountry, concontinent);
                MyCommand.ExecuteNonQuery();
                DataSet dscontinent = new DataSet();
                dacontinent.Fill(dscontinent);
                concontinent.Close();

                foreach (DataRow dtrow in dscontinent.Tables[0].Rows)
                {
                    string ContinentCode = dtrow["continent_code"].ToString();
                    string ContinentName = dtrow["continent_name"].ToString();
                    continentdetails.Add(new CascadingDropDownNameValue(ContinentName, ContinentCode));
                }

        }

        catch (Exception ex)
        {

        }
            return continentdetails.ToArray();
    }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...