|
Friday, 27 January 2012 10:39 |
// Bind dropwdown in gridview
protected void GvTestGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DataTable dtData= new DataTable();
dtData= GetData(); // Get your data to be binded to dropdown
DropDownList ddlFileData= (DropDownList)e.Row.FindControl("DdlFileData");
ddlFileData.Datasource = dtData;
ddlFileData.DataBind();
}
}
 Read more: |
|
Monday, 19 December 2011 02:18 |
This will help you only when you have to filter distinct records based on specified fields.
e.g. I have a table called UserDetail which contains the following fields:
UserID | Name | Mobile | Email | City | State
Now I want to only display distinct records with Name, City and State, then you can use:
string[] TobeDistinct = {"Name","City","State"};
DataTable dtDistinct = GetDistinctRecords(DTwithDuplicate, TobeDistinct);
//Following function will return Distinct records for Name, City and State column.
public static DataTable GetDistinctRecords(DataTable dt, string[] Columns)
{
DataTable dtUniqRecords = new DataTable();
dtUniqRecords = dt.DefaultView.ToTable(true, Columns);
return dtUniqRecords;
}
 Read more: |