Generate List with splitted record and adding key in c#

孤者浪人 提交于 2020-01-16 09:00:10

问题


I have a table with multicolumn and record is inserted with Pipe sign. This pipe sign is a indicator to insert a line break. "Column Name:Bedroom" "Record is like Flooring: Vitrified Tiles|Wall : Distemper|Ceiling : Oil Bound Distemper". similarly i have multiple columns with same type of record.

I want to display the records as shown in image below

I don't want to use loop and lengthy code. instead i would prefer List/Dictionary and in aspx page i would like to use Repeater. Code i am trying is available here for better understanding. I have added a # tag to identify the end of first column.

string Specs = dtprop.Rows[0]["SpecBedRoom"] + "#" + dtprop.Rows[0]["SpecLivingRoom"];

Specs = Specs.Replace("|", "<br/>");
List<string> InnerSpecs = Specs.Split('#').ToList<string>();
                    Dictionary<string, string> d = new Dictionary<string, string>();
                    d.Add("Bedroom", InnerSpecs[0].ToString());
                    d.Add("Living Room", InnerSpecs[1].ToString());

                    rptrInnerSpecs.DataSource = d;
                    rptrInnerSpecs.DataBind();

Your expertise is required for this.Please suggest.

来源:https://stackoverflow.com/questions/58669733/generate-list-with-splitted-record-and-adding-key-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!