Click here to Skip to main content
15,924,318 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dropdownlist as follows


To what way student is useful Dropdownlist1(Good,Fair,Poor)

When i select the Dropdpownlist1 in that select the Poor POPUP Screen will open. the POPUP Screen as follows

Negative_Feed_Back
Textbox1(In that textbox type the reason for Poor)
OK (Button)

When user click the OK (Button) the select dropdownlist and Remarks will be displayed in the gridview

In gridview as follows

Dropdown Remarks

0 Student performance is not good

Suppose if user wrongly type the reason for poor want to change means in that case he can change reason for poor and click the ok button.

In that case two Poor reasons are there in gridview as follows

Dropdown Remarks

0 Student performance is not good
0 The Students not good at all

in that case i want to delete the first First Row of the gridview.
Output as follows

Dropdown Remarks

0 The Students not good at all

how to delete the gridview using datatable in asp.net using C#.

My code as follows
C#
private void SetDropdowndetails(string Dropdownname, Int32 Dropdownid)
 {
      string SelectedDropdown = string.Empty;
     SelectedDropdown = Dropdownname.ToString();
     hfnegativefeedback.Value = Dropdownid.ToString();
     Negativepnlpopup();
 }

 private void Negativepnlpopup()
 {
    TxtNegativeFeedback.Text = "";
    DataTable dt = new DataTable();
    dt = (DataTable)ViewState["Remarks"];
    if (ViewState["Remarks"] != null)
    {
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            if (hfnegativefeedback.Value == dt.Rows[i][0].ToString())
            {
                TxtNegativeFeedback.Text = dt.Rows[i][1].ToString();
            }
        }
    }
         ModalPopupExtender1.TargetControlID = SelectedDropdown.ToString();
         TxtNegativeFeedback.Focus();
         ModalPopupExtender1.Show();
         Pnlnegativefeedback.Visible = true;
 }

In my above ocde in Negativepnlpopup function how to write the code for delete the duplicate rows in datatable in asp.net using C#.

Regards,
Narasiman P.
Posted
Updated 14-Nov-13 20:33pm
v2

1 solution

A solution to delete duplicate rows is :-
Datatable DtNew = DtData.DefaultView.ToTable(true, parameters); //replace parameters with field you want to check for duplicacy 
like
Datatable DtNew = DtData.DefaultView.ToTable(true, "Id", "Name"); 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900