ITsolutionWizard
asked on
webmethod, aspx, c#
I have the webmethod below and it works fine.
Now, I need to add database bind because I have gridview inside of this page. In this case, what can i do?
Now, I need to add database bind because I have gridview inside of this page. In this case, what can i do?
[WebMethod]
public static string RemoveXMLData(int messageID)
{
string result = "";
try
{
string templatePath = HttpContext.Current.Request.PhysicalApplicationPath + "UserMessages.xml";
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(templatePath);
try
{
XmlNodeList nodeList = xmlDoc.SelectNodes("Users/User[MessageID = " + messageID + "]");
foreach (XmlNode xn in nodeList)
{
xn.ParentNode.RemoveChild(xn);
}
result = "Data deleted";
}
catch { result = "Some error in node deletion"; }
finally
{
xmlDoc.Save(templatePath);
}
}
catch { result = "Eror in xml file loading"; }
return result;
}
html = html + "<ul class='list-unstyled'>" +
"<li class='left clearfix'>" +
"<span class='chat-img1 pull-left' style='vertical-align: text-top;'>" +
"<i class='fa fa-user-plus fa-2x' style='float:left;color:green;' aria-hidden=;true'></i>" +
"</span>" +
"<div class='chat-body1 clearfix'>" +
"<p>" + this.From +
" <input type='button' value='Mark as Read' class='btn btn-primary btn-xs' onclick='RemoveXMLData(\"" + this.MessageID + "\")'></button>" +
"</br></br>" + "<i style='width:300px;word-wrap: break-word;color=red;'>" + this.MessageBody + "</i>" + "</p>" +
"<div class='chat_time pull-right'><i>" + this.MesssageCreateDateTime + "</i></div>" +
"</div>" +
"</li>" +
"</ul>";
Are you asking how to bind the results of your webmethod to a gridview? If not, please clarify what you mean by "database bind".
ASKER
Like below:
public static string RemoveXMLData(int messageID)
{
// databind()
}
public static string RemoveXMLData(int messageID)
{
// databind()
}
ASKER
anyone can help?
What datasource are you trying to bind? The content of XmlDoc ? Or ?
ASKER
database.
ASKER
actually not database. xml
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It won't work inside of web method
Ah, ok.
You can't bind to a control inside of a webmethod.
You can't bind to a control inside of a webmethod.