hey I am new in c# and ASP.NET I created a form in which there are 4 dropdown list
like on the basis of ProjectID dropdown list FileID comes into FileID dropdown.Second is on the basis of FundType dropdown list FundID comes into FundID dropdown list.All are working fine but when I am going to submit these entries into database then FileID insert only one that is first one whatever you selected in FileID dropdown list.It taking only first FileID everytime.So for that WHAT SHOULD I DO?

Your description is not very clear. Do you have some relevant code you can show to better understand the problem.

my code is:

<td style="text-align: left">
 Project ID</td>
<td>
<asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList4_SelectedIndexChanged">
                </asp:DropDownList>
            </td>
            <td style="text-align: left">
                <asp:Label ID="Label1" runat="server" Text="File ID"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="DropDownList1" runat="server">
              </asp:DropDownList>
            </td>
            <td>
                <asp:DropDownList ID="DropDownList2" runat="server"  AutoPostBack="true" onselectedindexchanged="DropDownList2_SelectedIndexChanged">
                    <asp:ListItem>NRC</asp:ListItem>
                    <asp:ListItem>RC</asp:ListItem>
                    <asp:ListItem>Institutional</asp:ListItem>
                </asp:DropDownList>
            </td>
            <td>
                 </td>
            <td style="text-align: left">
                <asp:Label ID="Label5" runat="server" Text="Fund ID"></asp:Label>
            </td>
            <td>
                <asp:DropDownList ID="DropDownList3" runat="server">
                </asp:DropDownList>
            </td>


cs code:

 protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["SQLDbConnection"].ToString();
            SqlConnection connection = new SqlConnection(connectionString);
            connection.Open();
string sql = "SELECT FinacialYear FROM File_Info WHERE FileID='" + DropDownList1.SelectedItem.Text + "'";
            cmd1 = new SqlCommand(sql, connection);
            string y = (string)cmd1.ExecuteScalar();
string sql1 = "SELECT ProjectID FROM File_Info WHERE FileID='" + DropDownList1.SelectedItem.Text + "'";
            cmd1 = new SqlCommand(sql1, connection);
            string q = (string)cmd1.ExecuteScalar();
     SqlCommand cmd = new SqlCommand("SELECT FundID,Name FROM Fund_Booked WHERE HeadType='" + DropDownList2.SelectedItem.Text + "' AND YEAR='"+y+"' AND ProjectID='"+q+"'",connection);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
DropDownList3.DataSource = dt;
DropDownList3.DataTextField = "Name";
DropDownList3.DataValueField = "FundID";
DropDownList3.DataBind();
        }
protected void DropDownList4_SelectedIndexChanged(object sender, EventArgs e)
{
       string connectionString = ConfigurationManager.ConnectionStrings["SQLDbConnection"].ToString();
            SqlConnection connection = new SqlConnection(connectionString);
            connection.Open();
SqlCommand cmd = new SqlCommand("SELECT FileID,ProjectID FROM File_Info WHERE FinacialYear='" + DropDownList5.SelectedItem.Text + "' AND ProjectID='" + DropDownList4.SelectedItem.Text + "'", connection);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
DropDownList1.DataSource = dt;
DropDownList1.DataTextField = "FileID";
DropDownList1.DataValueField = "ProjectID";
DropDownList1.DataBind();
        }

FileID come according to the ProjectID that is working but when I am going to insert FileID then it insert only first fileID whatever I selected.Thats the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.