Click here to Skip to main content
15,919,358 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I m working on an web application which gives information of user which use specific mailing system
i get user name, mobilenumber,...., account lock status of user from oracle database.
this information is diplayed in Grid.
this is bound to webpage at runtime.
i m using web service to bind datagrid to page at runtime
i m asked to add one more column to this grid with name "Unlock user" which contains a link.
if 'account lock status' value taken from database is "Y" then i need to show the "unlock link" in "Unlock Column" else show nothing.
i have bound the column to grid
I have bound this column using XML document. now to fulfill the above requrement i need to put if condition in xml document sayinf if lock status=y then only bind value of unlock link else not.

currently since i have not put the condition i get unlock link in all rows of unlock column
here is xml line for binding the unlock column

C#
new XElement("cell", row["LOC_FLG"]),//to bind lock status flag to grid at runtime

new XElement("cell", "<img src='../Images/edit.gif' onClick=redirectpage('" + row["USER_ID"].ToString().Trim() + "'); ToolTip = 'Update'>" ),//to add unlock column and edit.gif is hyperlink to redirect to unlock page


can anyone tell me how to add if condition here
Posted
Updated 4-Aug-11 14:21pm
v3
Comments
BobJanova 4-Aug-11 8:25am    
What XML binding are you using? Check the information about how to construct that. I have not heard of XML binding so I can't really help.
Member 8081020 4-Aug-11 8:34am    
i m using web service to bind grid dynamically
which has code like this

List<datarow> data = (new FlexiGridCommon()).GetWebXml(dt, ref totalrows, ref page);
XDocument xmlDoc = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XElement("rows",
new XElement("page", page.ToString()),
new XElement("total", totalrows.ToString()),
new XElement("cell", row["LOC_FLG"]),//to bind lock status flag to grid at runtime

new XElement("cell", "<img src='../Images/edit.gif' önClick=redirectpage('" + row["USER_ID"].ToString().Trim() + "'); ToolTip = 'Update'>" )

i have bound the column just want to put if condition

1 solution

Maybe try...

new XElement("cell", row["LOC_FLAG"] == 'Y' ? "<img src='../Images/unlock.gif'  önClick=redirectpage('url'); ToolTip = 'Unlock'>" : "" )
 
Share this answer
 
v3
Comments
Member 8081020 5-Aug-11 1:57am    
thanks for solution but it didint work
fcronin 5-Aug-11 19:59pm    
Somehow it looks like the ? between 'Y' and "<img src=..." got turned into a colon... so I'm assuming you had a syntax error and couldn't compile. Change it as I did above and see if that gets your through... if not, what kind of error are you getting, or what is it not doing?
Member 8081020 8-Aug-11 1:29am    
Thanks for solution but I got answer i just did
new XElement("cell", "<img src='" + SetImageIFY(row["LOC_FLG"].ToString()) + "' önClick=redirectpageUnlock('" + row["USER_ID"].ToString().Trim() + "'); ToolTip = 'Unlock'>"),

and SetImageIFY(row["LOC_FLG"].ToString()) is function in which i put my condition
fcronin 8-Aug-11 10:29am    
Great, glad you managed it!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900