Hi All,
I am using Grid, in my grid I have footer in that footer I have
1 dropdown list with some fixed values here each item has separate ID [Value],
1 Textbox,
1 ADD Button.
Suppose In my Dropdown I have 5 Different Items with 5 Different Ids.
So my work is that I want to select one of the dropdown item & some text in Textbox & wants to INSERT that data into DB.
Here the problem is I want to add only 5 times & I didn’t want to select the repeated item in dropdown. If by mistake I select and Click on ADD button in footer it wants to show alert message. [Sorry this Item is already exists.]
So what to do????
Can any body help me???
MY CODE GOES LIKE THIS……
int
MyIAID = Convert.ToInt32(MYDROPDOWN.SelectedValue.ToString());
SqlCommand cmd = new SqlCommand("MYPROCEDURE", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@MYPARAMETER", MYVALUE);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds, "TABLENAME");
if (ds != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
{
int IAID =
Convert.ToInt32(ds.Tables[0].Rows[i]["XXX"]);
if (IAID == MyIAID)
{
if (!Page.IsStartupScriptRegistered("CH"))
{
Page.RegisterStartupScript("CH",
"<script>alert('This Record Is Already Exists.');</script>");
}
}
else
{
MY INSERTION CODE GOES HERE
}
}
}
}
Thanks in Advance,
Venki.