I am created document library in sharepoint online and i am uploaded data and document successfully but i have a problem when i am retrieving that datas, data is perfectly retrieving but document file retrieving from the sp. PLEASE see the code how i am retrieved the data and how to retrieve the document here i am use to retrieving the qualification when i am retrieving qualification it has to show all the data in the row document also but document is not displaying
And how to search document data using client side program.for example i am typing resume if any document inside resume data is having it has to highlight that and retrieve the file
what i have to do please help me
SharePointContextToken contextToken;
string accessToken;
Uri sharepointUrl;
protected void Page_Load(object sender, EventArgs e)
{
string contextTokenString = TokenHelper.GetContextTokenFromRequest(Request);
if (contextTokenString != null)
{
contextToken =
TokenHelper.ReadAndValidateContextToken(contextTokenString, Request.Url.Authority);
sharepointUrl = new Uri(Request.QueryString["SPHostUrl"]);
accessToken =
TokenHelper.GetAccessToken(contextToken, sharepointUrl.Authority).AccessToken;
Submit.CommandArgument = accessToken;
retrive.CommandArgument = accessToken;
}
if (IsPostBack)
{
sharepointUrl = new Uri(Request.QueryString["SPHostUrl"]);
}
//Execute a request to add a list that has the user-supplied name.
}
protected void Submit_Click(object sender, EventArgs e)
{
var accesssToken = ((Button)sender).CommandArgument;
if (IsPostBack)
{
sharepointUrl = new Uri(Request.QueryString["SPHostUrl"]);
}
//Execute a request to add a list that has the user-supplied name.
ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken(sharepointUrl.ToString(), accesssToken);
Web web = clientContext.Web;
ListCollection lists = web.Lists;
List List = clientContext.Web.Lists.GetByTitle("list name");
clientContext.Load(List);
DateTime dt = DateTime.Today;
ListItemCreationInformation listCreationInformation = new ListItemCreationInformation();
List documentsList = clientContext.Web.Lists.GetByTitle("list name");
var fileCreationInformation = new FileCreationInformation();
byte[] documentstream = System.IO.File.ReadAllBytes(browse.PostedFile.FileName);
fileCreationInformation.Content = documentstream;
fileCreationInformation.Url = browse.PostedFile.FileName;
fileCreationInformation.Overwrite = true;
Microsoft.SharePoint.Client.File uploadFile = documentsList.RootFolder.Files.Add(
fileCreationInformation);
uploadFile.ListItemAllFields["cname"] = cname.Text;
uploadFile.ListItemAllFields["qualification"] = qualification.Text;
uploadFile.ListItemAllFields["gender"] = gender.Text;
uploadFile.ListItemAllFields["address"] = address.Text;
uploadFile.ListItemAllFields["posting"] = posting.Text;
uploadFile.ListItemAllFields["domain"] = domain.Text;
uploadFile.ListItemAllFields["experience"] = experience.Text;
uploadFile.ListItemAllFields["salary"] = salary.Text;
uploadFile.ListItemAllFields.Update();
clientContext.Load(documentsList);
clientContext.ExecuteQuery();
try
{
clientContext.ExecuteQuery();
}
catch (Exception j)
{
Label2.Text = j.Message;
}
}
protected void retrive_Click(object sender, EventArgs e)
{
var accesssToken = ((Button)sender).CommandArgument;
if (IsPostBack)
{
sharepointUrl = new Uri(Request.QueryString["SPHostUrl"]);
}
ClientContext clientContext = TokenHelper.GetClientContextWithAccessToken(sharepointUrl.ToString(), accesssToken);
Web web = clientContext.Web;
ListCollection lists = web.Lists;
List List = clientContext.Web.Lists.GetByTitle("list name");
clientContext.Load(List);
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><Query><Where><Eq>" +
"<FieldRef Name ='qualification'/> <Value Type ='Text'>" + TextBox1.Text + "</Value>" +
"</Eq></Where></Query></View>";
//{ "herehere i have to use [AND] command to retrieve another value both same it has to retrieve " }am giving qualification data in the text box
Microsoft.SharePoint.Client.ListItemCollection items =CamlQuery List.GetItems(camlQuery);
clientContext.Load(items);
try
{
clientContext.ExecuteQuery();
}
catch (Exception er)
{
Label1.Text = er.Message;
}
foreach (Microsoft.SharePoint.Client.ListItem item in items)
{
TableRow tablerow = new TableRow();
TableCell tablecell1 = new TableCell();
TableCell tablecell2 = new TableCell();
TableCell tablecell3 = new TableCell();
TableCell tablecell4 = new TableCell();
TableCell tablecell5 = new TableCell();
TableCell tablecell6 = new TableCell();
TableCell tablecell7 = new TableCell();
TableCell tablecell8 = new TableCell();
TableCell tablecell9 = new TableCell();
tablecell1.Text = item.FieldValues["cname"].ToString();
tablecell2.Text = item.FieldValues["qualification"].ToString();
tablecell3.Text = item.FieldValues["gender"].ToString();
tablecell4.Text = item.FieldValues["address"].ToStringCamlQuery();
tablecell5camlQuery.TextViewXml = item.FieldValues["posting"].ToString();
tablecell6.Text ="<View><Query><Where><Eq>" item.FieldValues["domain"].ToString();+
tablecell7.Text = item.FieldValues["experience"].ToString();
"<FieldRef Name ='qualification'/> <Value Type ='Text'>" + tablecell8TextBox1.Text = item.FieldValues["salary"].ToString();
tablerow.Cells.Add(tablecell1);
tablerow.Cells.Add(tablecell2);
tablerow.Cells.Add(tablecell3);
tablerow.Cells.Add(tablecell4);
tablerow.Cells.Add(tablecell5);
tablerow.Cells.Add(tablecell6);
tablerow.Cells.Add(tablecell7);
tablerow.Cells.Add(tablecell8);
tablerow.Cells.Add(tablecell9);
+ "</Value>" ListTable.Rows.Add(tablerow);+
}
}
}
}"</Eq></Where></Query></View>";
I am created document library in sharepoint online and i uploaded data successfully but//{ "here i have a problem when i am retrieving the ["qualification = TextBox1.Text"]to retrieve more than one data so i haswill use [AND] command to display what all qualification same in the library . It displaying all theretrieve data but "document is not retrieved"how to use [And] i don't know please help me " }
And how to search inside the document data using client side program
Microsoft.SharePoint.Client.ListItemCollection items = List.GetItems(camlQuery);
clientContext.Load(items);
try
{
clientContext.ExecuteQuery();
}
catch (Exception er)
{
Label1.Text = er.Message;
}
foreach (Microsoft.SharePoint.Client.ListItem item in items)
{
TableRow tablerow = new TableRow();
TableCell tablecell1 = new TableCell();
TableCell tablecell2 = new TableCell();
TableCell tablecell3 = new TableCell();
TableCell tablecell4 = new TableCell();
TableCell tablecell5 = new TableCell();
TableCell tablecell6 = new TableCell();
TableCell tablecell7 = new TableCell();
TableCell tablecell8 = new TableCell();
TableCell tablecell9 = new TableCell();
tablecell1.Text = item.FieldValues["cname"].ToString();
tablecell2.Text = item.FieldValues["qualification"].ToString();
tablecell3.Text = item.FieldValues["gender"].ToString();
tablecell4.Text = item.FieldValues["address"].ToString();
tablecell5.Text = item.FieldValues["posting"].ToString();
tablecell6.Text = item.FieldValues["domain"].ToString();
tablecell7.Text = item.FieldValues["experience"].ToString();
tablecell8.Text = item.FieldValues["salary"].ToString();
tablecell9.Text = item.FieldValues["document"].ToString();
// //here i have to retrieve file document.how to change it byte type and how it show i don't know here what i have to do please help me
tablerow.Cells.Add(tablecell1); tablerow.Cells.Add(tablecell2); tablerow.Cells.Add(tablecell3); tablerow.Cells.Add(tablecell4); tablerow.Cells.Add(tablecell5); tablerow.Cells.Add(tablecell6); tablerow.Cells.Add(tablecell7); tablerow.Cells.Add(tablecell8); tablerow.Cells.Add(tablecell9); ListTable.Rows.Add(tablerow);
}
}
}
}