@Frinavale
Yes, Actually I wanted a initially to display only titles, so I first went for ObjectDataSource(ODS), but then I wanted concatenation of title/author, so went for generic list, which I was partially aware of and
did this way
And I concatenated as
- ddlKeys.DataTextField = "KeyValue ";
Infact I call a method where I populate the generic list as below
- private void TGenerateKeys<T>(SqlDataReader returnData, ref List<Keys> KeysList)
-
{
-
while (returnData.Read())
-
{
-
Keys oKeys = new Keys();
-
oKeys.KeyValue = Convert.ToString(returnData["TITLE"]) + "/" + Convert.ToString(returnData["AUTHOR"]);
-
-
KeysList.Add(oKeys);
-
}
-
}
But although I have not implemented, I think, while retrieving query from sql server, I can put something as
select title+author as "Both" from tablename
and directly bind this value to ODS.
Of course I can bind the "KeyValue", field too, but I had one more work, I had to include a value called as "All", so if the user chooses "All", I should be able to display all the results.
If I add it through properties (I mean press F4 on dropdownlist), then although I select other titles, the dropdownlist always showed "All".(because I gave selected =true in dropdownlist)
I thought it would be easier if I dynamically populate the dropdownlist and after binding to the above list. I followed this code
- List<Keys> olistkeys=Keys.GetKeysByEmailId(txtEmail.Text);
-
ddlKeys.DataSource = olistkeys;
-
ddlKeys.DataTextField = "keyvalue";
-
ddlKeys.DataBind();
and later added the "All" as
- ddlKeys.Items.Add(new ListItem("All", "0"));
And resolved my issues.
Sorry for dragging this to such a length, and pls excuse my English.
Regards
cmrhema