locked
why dropdownlist have null ? RRS feed

  • Question

  • User-1998474842 posted

    Hi guys

    why drop-down list have null?

    <asp:DropDownList ID="DropDownListKat" runat="server">
    <asp:ListItem Selected="True" Value="White"> White </asp:ListItem>
    <asp:ListItem Value="Silver"> Silver </asp:ListItem>
    <asp:ListItem Value="DarkGray"> Dark Gray </asp:ListItem>
    <asp:ListItem Value="Khaki"> Khaki </asp:ListItem>
    <asp:ListItem Value="DarkKhaki"> Dark Khaki </asp:ListItem>
    </asp:DropDownList>

        protected void Save_Click(object sender, EventArgs e)
        {
            DataAcess data = new DataAcess();
            for (int i = 0; i < GridView2.Rows.Count; i++)
            {
                TextBox PRID = (TextBox)GridView2.Rows[i].FindControl("PRID");//8
                String COID = Request.QueryString["COID"];
                String COBUID = Request.QueryString["COBUID"];
                String COBULEID = Request.QueryString["COBULEID"];
                String COBULEAPID = Request.QueryString["COBULEAPID"];
                TextBox Basket_Quantities = (TextBox)GridView2.Rows[i].FindControl("Basket_Quantities");//8
                TextBox Phone_No = (TextBox)GridView2.FooterRow.FindControl("Phone_No");//8
                DropDownList DropDownListKat = (DropDownList)GridView2.FooterRow.Cells[i].FindControl("DropDownListKat");
                string sql = "INSERT INTO Dawabka_Basket (PRID, COID, COBUID, COBULEID, COBULEAPID, Basket_Quantities, Phone_No, DKat ) VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7} )";
                sql = string.Format(sql, PRID.Text, COID, COBUID, COBULEID, COBULEAPID, Basket_Quantities.Text, Phone_No.Text, DropDownListKat.SelectedValue.ToString() );
                data.Exe_cmd(sql);
    
                //HttpContext.Current.Session.Remove("basket");
                //HttpContext.Current.Session.Abandon();
                //Response.Redirect("Bo_Tosh.aspx");
            }
    
    
        }

    Saturday, January 5, 2019 10:46 AM

Answers

  • User475983607 posted

    peshangm

    I think my problem in the string format  below

    sql = string.Format(sql, PRID.Text, COID, COBUID, COBULEID, COBULEAPID, Basket_Quantities.Text, Phone_No.Text, DropDownListKat.SelectedItem.Value);

    For the third time!  This line of code is indexing through the GridView columns!!!

    DropDownList DropDownListKat = (DropDownList)GridView2.FooterRow.Cells[i].FindControl("DropDownListKat");
                

    The for...loop that populates "i" is looping over GridView row indexes.

    for (int i = 0; i < GridView2.Rows.Count; i++)
    {

    There is absolutely no indication that the QueryString values exist!

    for (int i = 0; i < GridView2.Rows.Count; i++)
            {
                TextBox PRID = (TextBox)GridView2.Rows[i].FindControl("PRID");//8
                String COID = Request.QueryString["COID"];
                String COBUID = Request.QueryString["COBUID"];
                String COBULEID = Request.QueryString["COBULEID"];
                String COBULEAPID = Request.QueryString["COBULEAPID"];
                TextBox Basket_Quantities = (TextBox)GridView2.Rows[i].FindControl("Basket_Quantities");//8
                TextBox Phone_No = (TextBox)GridView2.FooterRow.FindControl("Phone_No");//8
                DropDownList DropDownListKat = (DropDownList)GridView2.FooterRow.Cells[i].FindControl("DropDownListKat");
                string sql = "INSERT INTO Dawabka_Basket (PRID, COID, COBUID, COBULEID, COBULEAPID, Basket_Quantities, Phone_No, DKat ) VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7} )";
                sql = string.Format(sql, PRID.Text, COID, COBUID, COBULEID, COBULEAPID, Basket_Quantities.Text, Phone_No.Text, DropDownListKat.SelectedValue.ToString() );
                data.Exe_cmd(sql);
    
                //HttpContext.Current.Session.Remove("basket");
                //HttpContext.Current.Session.Abandon();
                //Response.Redirect("Bo_Tosh.aspx");
            }

    It is not clear why you are reassigning the same static values in the for...loop over and over.

    As far as I can tell you are not setting a break point and debugging or you do not know how to use the debugger.  The watch window will let you drill into whatever variable you like.  The immediate window will let you invoke code, real-time, against the current call stack state.

    There is a lot if state logic and there's no way to determine what values exist in state when the Save button is clicked.  IMHO, the code is overly complex and needs to be simplified - refactored - redeigned.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 5, 2019 6:43 PM

All replies

  • User475983607 posted

    The logic does not make sense as i is the row enumerator but you are using as a column enumerator.  Please set a breakpoint and debug your code.

    DropDownList DropDownListKat = (DropDownList)GridView2.FooterRow.Cells[i].FindControl("DropDownListKat");

    Saturday, January 5, 2019 2:53 PM
  • User-1998474842 posted

    I try this way but also this is null

    Saturday, January 5, 2019 5:20 PM
  • User475983607 posted

    I try this way but also this is null

    What way? 

    There is simply not enough code to provide an accurate solution.  Please set a break point and debug the code.  If you need the community to debug your code then post sample code that reproduces the issue.  Please do not make us guess over multiple threads...

    Saturday, January 5, 2019 5:26 PM
  • User-1998474842 posted

    this is full code , this the value of this ddl is always null and the record is not add to data base 

    using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    
    public partial class App_Languages_Languages_Kurdish_App_Kren_Bo_Zamila : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
            System.Threading.Thread.Sleep(3000);
    
            DataTable Basket_DataTable = null;
            if (!Page.IsPostBack)
            {
                System.Threading.Thread.Sleep(1500);
    
                if (Session["basket"] != null)
                    ///read Basket_DataTable from session if exist
                    Basket_DataTable = (DataTable)Session["basket"];
                else
                {
                    //create an empty DataTable and Add some columns to it
                    Basket_DataTable = new DataTable();
                    Basket_DataTable.Columns.Add("PRID");
                    Basket_DataTable.Columns.Add("COID");
                    Basket_DataTable.Columns.Add("COBUID");
                    Basket_DataTable.Columns.Add("COBULEID");
                    Basket_DataTable.Columns.Add("COBULEAPID");
                    Basket_DataTable.Columns.Add("Product_Names");
                    Basket_DataTable.Columns.Add("Product_Price");
                    Basket_DataTable.Columns.Add("Product_Images");
                    Basket_DataTable.Columns.Add("Basket_Quantities");
                    Basket_DataTable.Columns.Add("Basket_Amount");
                }
                /////////////////////////
                if (Request["DelID"] != null)
                {
                    for (int i = 0; i < Basket_DataTable.Rows.Count; i++)
                        if (Basket_DataTable.Rows[i][0].ToString() == Request["DelID"].ToString())
                            Basket_DataTable.Rows.Remove(Basket_DataTable.Rows[i]);
    
                }
    
                if (Request["PRID"] != null)
                {
                    //search item in DataTable
                    bool Found = false;
                    for (int i = 0; i < Basket_DataTable.Rows.Count; i++)
                        if (Basket_DataTable.Rows[i][0].ToString() == Request["PRID"].ToString())
                            Found = true;
    
                    //add to basket
                    if (Found == false)
                    {
                        DataAcess data = new DataAcess();
                        string sql = "SELECT * FROM Dawabka_Cat_Com_Pak_Siz_Products where PRID=" + Request["PRID"];
                        DataTable ret = data.Exe_select(sql);
                        if (ret != null && ret.Rows.Count == 1)
                        {
                            Basket_DataTable.Rows.Add(new object[] { Request["PRID"]
                                                  ,Request["COID"]
                                                  ,Request["COBUID"]
                                                  ,Request["COBULEID"]
                                                  ,Request["COBULEAPID"]
                                                  ,ret.Rows[0]["Product_Names"].ToString()
                                                  ,ret.Rows[0]["Product_Price"].ToString()
                                                  ,ret.Rows[0]["Product_Images"].ToString()
                                                  ,"1"
                                                  ,ret.Rows[0]["Product_Price"].ToString()});
                        }
                    }
                }
    
                if (IsPostBack == false)
                {
                    GridView2.DataSource = Basket_DataTable;
                    GridView2.DataBind();
                }
                Session["basket"] = Basket_DataTable;
    
    
                //Call BindList Contate page
                ViewState["Start"] = 0;
                BindList1();
    
    
            }
            link1.Attributes["href"] = "Bo_Zamila.aspx?COID=" + Request.QueryString["COID"] + "&COBUID=" + Request.QueryString["COBUID"] + "&COBULEID=" + Request.QueryString["COBULEID"] + "&COBULEAPID=" + Request.QueryString["COBULEAPID"];
        }
    
        protected void Save_Click(object sender, EventArgs e)
        {
            DataAcess data = new DataAcess();
            for (int i = 0; i < GridView2.Rows.Count; i++)
            {
                TextBox PRID = (TextBox)GridView2.Rows[i].FindControl("PRID");//8
                String COID = Request.QueryString["COID"];
                String COBUID = Request.QueryString["COBUID"];
                String COBULEID = Request.QueryString["COBULEID"];
                String COBULEAPID = Request.QueryString["COBULEAPID"];
                TextBox Basket_Quantities = (TextBox)GridView2.Rows[i].FindControl("Basket_Quantities");//8
                TextBox Phone_No = (TextBox)GridView2.FooterRow.FindControl("Phone_No");//8
                DropDownList DropDownListKat = (DropDownList)GridView2.FooterRow.Cells[i].FindControl("DropDownListKat");
                string sql = "INSERT INTO Dawabka_Basket (PRID, COID, COBUID, COBULEID, COBULEAPID, Basket_Quantities, Phone_No, DKat ) VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7} )";
                sql = string.Format(sql, PRID.Text, COID, COBUID, COBULEID, COBULEAPID, Basket_Quantities.Text, Phone_No.Text, DropDownListKat.SelectedValue.ToString());
                data.Exe_cmd(sql);
    
                //HttpContext.Current.Session.Remove("basket");
                //HttpContext.Current.Session.Abandon();
                //Response.Redirect("Bo_Tosh.aspx");
            }
    
    
        }
        protected void GridView2_DataBound(object sender, System.EventArgs e)
        {
            Label3.Text = "&nbsp;" + GridView2.Rows.Count.ToString() + "&nbsp;&nbsp;نرخی گه‌یاندن 500 دینار.";
        }
    
        //Bindlist Datasource
        public void BindList1()
        {
            //no data in QueryString
            if (Request.QueryString["COID"] == null & Request.QueryString["COBUID"] == null & Request.QueryString["COBULEID"] == null & Request.QueryString["COBULEAPID"] == null)
            {
                Repeater5.Visible = false;
    
            }
            //+Insurance data + Region data + Cat data
            else if (Request.QueryString["COID"] != null & Request.QueryString["COBUID"] != null & Request.QueryString["COBULEID"] != null & Request.QueryString["COBULEAPID"] != null)
            {
                Repeater5.Visible = true;
            }
        }
        protected void Chainge_Location_Click(object sender, EventArgs e)
        {
    
            string url = Request.Url.AbsolutePath;
            HttpContext.Current.Session.Remove("basket");
            HttpContext.Current.Session.Abandon();
    
            Response.Redirect("~/App_Languages/Languages_Kurdish/App_Kren/Bo_Kren.aspx");
        }
    
    
        protected void Button1_Click(object sender, EventArgs e)
        {
            Response.Redirect("Bo_Kren.aspx?COID=" + Request.QueryString["COID"] + "&COBUID=" + Request.QueryString["COBUID"] + "&COBULEID=" + Request.QueryString["COBULEID"] + "&COBULEAPID=" + Request.QueryString["COBULEAPID"]);
        }
    }
    <%@ Page  Language="C#"  MasterPageFile="~/App_Templet/App_Templet_Kurdish/Full_Width.master" AutoEventWireup="true" CodeFile="Bo_Zamila.aspx.cs" Inherits="App_Languages_Languages_Kurdish_App_Kren_Bo_Zamila" %>
    
    <asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="Server">
        <style>
            input[type=number]::-webkit-inner-spin-button { opacity: 1; }
        </style>
    </asp:Content>
    <asp:Content ID="bar" ContentPlaceHolderID="Nawarokbar" runat="Server">
        <div class="s-12 m-12 l-12 margin-bottom">
            <div class="ShwenYakakan margin-bottom">
                <div class="Location">
                    <asp:Repeater ID="Repeater5" Visible="false" runat="server" DataSourceID="AccessDataSource1">
                        <ItemTemplate>
                            <div style="float: right">
                                <asp:LinkButton ID="LinkButton1" runat="server" OnClick="Chainge_Location_Click">
                                    <img id="DelLo" alt="گۆڕینی یه‌که‌ی نیشته‌جێبوون" runat="server" src="~/App_Themes/Themes_Kurdish/PMN_Shewa_Yak/Images/DelLo.png" width="25" height="25">
                                </asp:LinkButton>
                            </div>
                            <div style="float: right; font-size: 15px;">
                                &nbsp;<asp:Label ID="Compound_Names_Ku" runat="server" Text='<%# Bind("Compound_Names_Ku") %>'></asp:Label>
                                &nbsp;ب/&nbsp;<asp:Label ID="Buildings_Names" runat="server" Text='<%# Bind("Buildings_Names") %>'></asp:Label>
                                &nbsp;ن/&nbsp;<asp:Label ID="Apartment_NO" runat="server" Text='<%# Bind("Level_NO") %>'></asp:Label>
                                &nbsp;د/‌&nbsp;<asp:Label ID="Level_NO" runat="server" Text='<%# Bind("Apartment_NO") %>'></asp:Label>&nbsp;
                            </div>
                            <div style="clear: both" />
                        </ItemTemplate>
                    </asp:Repeater>
                    <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/DAWABKADBKU.mdb" SelectCommand="SELECT Dawabka_Com_Buildings_Levels_Apart.COID, Dawabka_Com.Compound_Names_Ku, Dawabka_Com_Buildings_Levels_Apart.COBUID, Dawabka_Com_Buildings.Buildings_Names, Dawabka_Com_Buildings_Levels_Apart.COBULEID, Dawabka_Com_Buildings_Levels.Level_NO, Dawabka_Com_Buildings_Levels_Apart.COBULEAPID, Dawabka_Com_Buildings_Levels_Apart.Apartment_NO FROM (((Dawabka_Com INNER JOIN Dawabka_Com_Buildings_Levels_Apart ON Dawabka_Com.COID = Dawabka_Com_Buildings_Levels_Apart.COID) INNER JOIN Dawabka_Com_Buildings ON Dawabka_Com_Buildings_Levels_Apart.COBUID = Dawabka_Com_Buildings.COBUID) INNER JOIN Dawabka_Com_Buildings_Levels ON Dawabka_Com_Buildings_Levels_Apart.COBULEID = Dawabka_Com_Buildings_Levels.COBULEID) WHERE (Dawabka_Com_Buildings_Levels_Apart.COID = ?) AND (Dawabka_Com_Buildings_Levels_Apart.COBUID = ?) AND (Dawabka_Com_Buildings_Levels_Apart.COBULEID = ?) AND (Dawabka_Com_Buildings_Levels_Apart.COBULEAPID = ?)">
                        <SelectParameters>
                            <asp:QueryStringParameter Name="?" QueryStringField="COID" />
                            <asp:QueryStringParameter Name="?" QueryStringField="COBUID" />
                            <asp:QueryStringParameter DefaultValue="" Name="?" QueryStringField="COBULEID" />
                            <asp:QueryStringParameter DefaultValue="" Name="?" QueryStringField="COBULEAPID" />
                        </SelectParameters>
                    </asp:AccessDataSource>
                </div>
            </div>
        </div>
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="Nawarok" runat="Server">
        <div class="s-12 m-12 l-12 margin-bottom">
            <div style="margin-left: auto; margin-right: auto; display: block; text-align: center; font-weight: 600; width: 380px;">
                <asp:Image ImageAlign="Middle" Style="margin-left: auto; margin-right: auto; display: block;" ID="SetLo" runat="server" OnClick="Chainge_Location_Click" ImageUrl="~/App_Themes/Themes_Kurdish/PMN_Shewa_Yak/Images/setLo.png" />
                <br />
                به‌کارهێنه‌ری خۆشه‌ویست نرخی گه‌یاندن 500 دینار.
                        <br />
            </div>
            <asp:GridView ID="GridView2" OnDataBound="GridView2_DataBound" runat="server" ShowFooter="true" ShowHeader="true" AutoGenerateColumns="False" DataKeyNames="PRID" CellPadding="0" GridLines="Horizontal">
                <Columns>
                    <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderText="پسوڵه‌ی کڕینم">
                        <ItemTemplate>
                            <div style="padding: 1px">
                                <div style="width: 90px; height: 80px; margin-left: 10px; float: right; margin-left: 5px;">
                                    <asp:HyperLink itemprop="url" ID="PMN_Pega_Viewmore" ValidationGroup="dropd" runat="server" NavigateUrl='<%# Eval("PRID", "?DelID={0}&COID=" + Request.QueryString["COID"] + "&COBUID=" + Request.QueryString["COBUID"] + "&COBULEID=" + Request.QueryString["COBULEID"] + "&COBULEAPID=" + Request.QueryString["COBULEAPID"] + "") %>'>
                                       <img Width="25" Height="25" style="; z-index:2;"  src="~/App_Themes/Themes_Kurdish/PMN_Shewa_Yak/Images/del.png" runat="server" />
                                    </asp:HyperLink>
                                    <asp:Image Visible="true" Style="; z-index: 1;" ID="Image1" runat="server" Height="75px" Width="85px" ImageUrl='<%# Eval("Product_Images") %>' />
                                </div>
                                <div style="width: 130px; padding-left: 10px; text-align: center; font-size: 14px; height: 80px; margin-left: 10px; float: right; margin-left: 5px;">
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("Product_Names") %>'></asp:Label>
                                    <br />
                                    <br />
                                    نرخ:
                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("Product_Price") %>'></asp:Label>
                                    دینار
                                </div>
                                <div style="width: 50px; direction: ltr; height: 80px; margin-left: 10px; float: right; margin-left: 5px; border-right-style: dotted; border-right-width: 1px; border-right-color: #ccc6c6;">
                                    <asp:TextBox type="number" ID="Basket_Quantities" Width="40px" Height="75px" runat="server" Text='<%# Bind("Basket_Quantities") %>' min="1" max="10"></asp:TextBox>
                                    <asp:TextBox type="number" Visible="false" ID="PRID" runat="server" Text='<%# Bind("PRID") %>'></asp:TextBox>
                                </div>
                                <div class="clear"></div>
                            </div>
                        </ItemTemplate>
                        <FooterTemplate>
                            <div style="direction: ltr; text-align: center;">
                                <asp:RequiredFieldValidator ValidationGroup="phone" runat="server" Display="dynamic" ID="valRequireSubject" SetFocusOnError="true" ControlToValidate="Phone_No" ErrorMessage="ژماره‌ی ته‌له‌فۆن‌">ژماره‌ی ته‌له‌فۆن</asp:RequiredFieldValidator>
                                <asp:TextBox ID="Phone_No" type="tel" runat="server" Font-Size="14px" placeholder="‌‌" BorderColor="Red" BorderStyle="Dotted" BorderWidth="1px" AutoCompleteType="Disabled" MaxLength="11" Width="100%"></asp:TextBox>
                                <br /> 
                                
                                <br />
                                <asp:DropDownList ID="DropDownListKat" runat="server">
                                    <asp:ListItem Selected="True" Value="ww">tt</asp:ListItem>
                                    <asp:ListItem Value="Silver"> Silver </asp:ListItem>
                                    <asp:ListItem Value="DarkGray"> Dark Gray </asp:ListItem>
                                    <asp:ListItem Value="Khaki"> Khaki </asp:ListItem>
                                    <asp:ListItem Value="DarkKhaki"> Dark Khaki </asp:ListItem>
                                </asp:DropDownList>
    
                                <select id="ddlm">
                                    <option value="tt">gg</option>
                                </select>
    
                                <br />
    
                                <asp:Button ID="save" ValidationGroup="phone" ForeColor="green" BorderStyle="Dotted" BorderWidth="1px" runat="server" Text="بۆم بێنه‌" OnClick="Save_Click" Width="100%" />
                            </div>
                        </FooterTemplate>
                        <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                    </asp:TemplateField>
                </Columns>
                <EmptyDataRowStyle Font-Size="15px" HorizontalAlign="Center" />
                <EmptyDataTemplate>
                    <div style="margin-left: auto; margin-right: auto; display: block; text-align: center; width: 250px;">
                        <asp:Label ID="SetLoTxt" ForeColor="#ff6a00" runat="server" Text="هیچ به‌رهه‌مێک دیاری نه‌کراوه‌ بۆ کڕین‌"></asp:Label>
                        <br />
                        <br />
                        <asp:Image ImageAlign="Middle" Style="margin-left: auto; margin-right: auto; display: block;" ID="SetLo" runat="server" OnClick="Chainge_Location_Click" ImageUrl="~/App_Themes/Themes_Kurdish/PMN_Shewa_Yak/Images/ba.png" Width="40px" Height="40px" />
                        <br />
                        <asp:Button ID="Button1" runat="server" Text="بۆ كرین تکایه‌ کلیک لێره‌ بکه" OnClick="Button1_Click" />
                    </div>
                </EmptyDataTemplate>
            </asp:GridView>
        </div>
        <br />
        <br />
        <br />
        <br />
    </asp:Content>
    <asp:Content ID="Content3" ContentPlaceHolderID="Zamila" runat="Server">
        <a id="link1" runat="server">
            <span class="bell">
                <img alt="پسوڵه" src="~/App_Themes/Themes_Kurdish/PMN_Shewa_Yak/Images/Ba.png" runat="server" />
                <asp:Label CssClass="bellnumbers" ID="Label3" runat="server" Text="کڕین"></asp:Label></span>
        </a>
    </asp:Content>
    
    

    Saturday, January 5, 2019 5:36 PM
  • User475983607 posted

    There's too many logical issues with the code and I do not understand the design.  

    Please learn how to use the Visual Studio debugger to debug the design.  

    https://docs.microsoft.com/en-us/visualstudio/debugger/navigating-through-code-with-the-debugger?view=vs-2015

    Saturday, January 5, 2019 5:49 PM
  • User-1998474842 posted

    my problem just in select value 

    Saturday, January 5, 2019 6:01 PM
  • User475983607 posted

    Well, you still have not fixed the index logical error that I pointed out in my first response. The for loop enumerates rows but you are using as a cell indexer in the footer. Please use the visual studio debugger to review your logic.

    I assume this will get the dropdown in the footer.

    DropDownList DropDownListKat = (DropDownList)GridView2.FooterRow.FindControl("DropDownListKat");

    It's not clear why this line and the QueryString values are within a loop.  A GridView has a single footer and there is only one querystring value.  I simply do not understand the design.

    Saturday, January 5, 2019 6:05 PM
  • User-1998474842 posted

    I think my problem in the string format  below

    sql = string.Format(sql, PRID.Text, COID, COBUID, COBULEID, COBULEAPID, Basket_Quantities.Text, Phone_No.Text, DropDownListKat.SelectedItem.Value);

    Saturday, January 5, 2019 6:22 PM
  • User-1998474842 posted

    in the debug it say null value 

    Saturday, January 5, 2019 6:31 PM
  • User475983607 posted

    peshangm

    I think my problem in the string format  below

    sql = string.Format(sql, PRID.Text, COID, COBUID, COBULEID, COBULEAPID, Basket_Quantities.Text, Phone_No.Text, DropDownListKat.SelectedItem.Value);

    For the third time!  This line of code is indexing through the GridView columns!!!

    DropDownList DropDownListKat = (DropDownList)GridView2.FooterRow.Cells[i].FindControl("DropDownListKat");
                

    The for...loop that populates "i" is looping over GridView row indexes.

    for (int i = 0; i < GridView2.Rows.Count; i++)
    {

    There is absolutely no indication that the QueryString values exist!

    for (int i = 0; i < GridView2.Rows.Count; i++)
            {
                TextBox PRID = (TextBox)GridView2.Rows[i].FindControl("PRID");//8
                String COID = Request.QueryString["COID"];
                String COBUID = Request.QueryString["COBUID"];
                String COBULEID = Request.QueryString["COBULEID"];
                String COBULEAPID = Request.QueryString["COBULEAPID"];
                TextBox Basket_Quantities = (TextBox)GridView2.Rows[i].FindControl("Basket_Quantities");//8
                TextBox Phone_No = (TextBox)GridView2.FooterRow.FindControl("Phone_No");//8
                DropDownList DropDownListKat = (DropDownList)GridView2.FooterRow.Cells[i].FindControl("DropDownListKat");
                string sql = "INSERT INTO Dawabka_Basket (PRID, COID, COBUID, COBULEID, COBULEAPID, Basket_Quantities, Phone_No, DKat ) VALUES ({0}, {1}, {2}, {3}, {4}, {5}, {6}, {7} )";
                sql = string.Format(sql, PRID.Text, COID, COBUID, COBULEID, COBULEAPID, Basket_Quantities.Text, Phone_No.Text, DropDownListKat.SelectedValue.ToString() );
                data.Exe_cmd(sql);
    
                //HttpContext.Current.Session.Remove("basket");
                //HttpContext.Current.Session.Abandon();
                //Response.Redirect("Bo_Tosh.aspx");
            }

    It is not clear why you are reassigning the same static values in the for...loop over and over.

    As far as I can tell you are not setting a break point and debugging or you do not know how to use the debugger.  The watch window will let you drill into whatever variable you like.  The immediate window will let you invoke code, real-time, against the current call stack state.

    There is a lot if state logic and there's no way to determine what values exist in state when the Save button is clicked.  IMHO, the code is overly complex and needs to be simplified - refactored - redeigned.  

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, January 5, 2019 6:43 PM
  • User-1998474842 posted

    could you please write your email I will send my project to you

    Saturday, January 5, 2019 6:46 PM