如何使用c#删除asp.net中datatable中的重复行 [英] how to delete the duplicate rows in datatable in asp.net using c#
问题描述
下拉列表如下
学生用什么方式有用Dropdownlist1(好,一般,差)
当我选择Dropdpownlist1时,选择将打开穷人POPUP屏幕。 POPUP屏幕如下
Negative_Feed_Back
Textbox1(在该文本框中键入差的原因)
OK (按钮)
当用户点击OK(按钮)时,选择下拉列表和备注将显示在gridview中
在gridview中如下
下拉备注
0学生表现不佳
假设用户错误地输入了想要改变的原因意味着在这种情况下他可以改变穷人的理由并点击确定按钮。
在这种情况下,两个糟糕的理由在gridview中如下
下拉备注
0学生表现不佳
0学生不擅长
在这种情况下我要删除第一个gridview的第一行。
输出如下
下拉备注
0学生不好在所有
如何使用C#在asp.net中使用数据表删除gridview。
我的代码如下
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 [ 备注];
if (ViewState [ 备注]!= null )
{
for ( int i = 0 ; i < dt.Rows .Count之间;我++)
{
<跨度类= 代码关键字>如果跨度>(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 ;
}
在我上面的Negativepnlpopup函数中,如何使用C#编写用于删除asp.net中datatable中重复行的代码。
问候,
Narasiman P.
删除解决方案重复的行是: -
Datatable DtNew = DtData.DefaultView.ToTable(true,parameters); //用你要检查重复项的字段替换参数比如
Datatable DtNew = DtData.DefaultView.ToTable(true,Id,名称);
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
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.
A solution to delete duplicate rows is :-
Datatable DtNew = DtData.DefaultView.ToTable(true, parameters); //replace parameters with field you want to check for duplicacylike
Datatable DtNew = DtData.DefaultView.ToTable(true, "Id", "Name");
这篇关于如何使用c#删除asp.net中datatable中的重复行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!