Hi,
I'm new to Syncfusion, and in the process of trying out a few different things to try to figure out how everything works. I'm using ASP.NET Web Forms, and I have a question about how to display text instead of value in a dropdownedit column.
I used the example from
this link to populate the dropdown values, and it does work fine when I try to add a new row. It shows the text instead of the value in the dropdown from the datasource I provided. But as far as the grid itself is concerned, it only shows the values, and not the text itself.
This is my grid:
<ej:Grid ID="buildingsGrid" runat='server' AllowPaging="true" AllowSorting="true" AllowFiltering="true" OnServerAddRow="buildingsGrid_ServerAddRow" OnServerDeleteRow="buildingsGrid_ServerDeleteRow">
<Columns>
<ej:Column Field="UserBuildingID" IsPrimaryKey="true" Visible="false"></ej:Column>
<ej:Column Field="buildingid" HeaderText="Building" EditType="DropdownEdit"></ej:Column>
</Columns>
<EditSettings AllowAdding="true" AllowEditing="false" AllowDeleting="true" />
<ToolbarSettings ShowToolbar="true" ToolbarItems="add,delete,update,cancel"></ToolbarSettings>
</ej:Grid>
I databind it at PageLoad, and databind the dropdown as well. The datatable that's used as the datasource for the grid returns three columns: UserBuildingID, buildingid and Name. Here the buildingid and Name are connected, and I want to display the Name instead of buildingid, but the value should still be buildingid.
For databinding the dropdown column, this is what I use:
List<
object
> dropObj =
new
List<
object
>();
using
(SqlDataReader dr = cmd.ExecuteReader())
{
while
(dr.Read())
{
dropObj.Add(
new
{ text = dr.GetValue(0).ToString(), value = dr.GetValue(0) });
}
}
this
.buildingsGrid.Columns[1].DataSource = dropObj;
How do I make sure that the text is displayed instead of the value in such a scenario?
Thanks,
Rajkishan