To hid unapproved content in SPQuery object set the following property in code behind
as the following.
query.ViewAttributes = "Scope='Recursive' ModerationType='HideUnapproved'";
Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts
2010/01/02
2009/12/30
Problem of postBack in sharepoint
while dealing with Response.End() I found that the postback events are disabled. I posted to MSDN Forum and thy responded on my post by the following:
Try to add this code to onClienClick event of the button to enable sharepoint post back event as the following
ButtonName.OnClientClick = "_spFormOnSubmitCalled = false;_spSuppressFormOnSubmitWrapper=true;";
my post on the following URL
Try to add this code to onClienClick event of the button to enable sharepoint post back event as the following
ButtonName.OnClientClick = "_spFormOnSubmitCalled = false;_spSuppressFormOnSubmitWrapper=true;";
my post on the following URL
التسميات:
C#,
SharePoint
2009/11/04
Export dataGrid to excel
if you need to export dataGrid to excel sheet you can do it as the following.
1- get dataGrid object with data.
2- create object of HtmlTextWriter.
3- try to write the Grid using HtmlTextWriter in you response.
as the following in button_Click event of any other location you want to perform this action.
string attachment = "attachment; filename=RegisteredUsers.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Charset = "UTF-8";
Response.ContentType = "application/vnd.ms-excel";
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
System.IO.StringWriter stringWriter = new System.IO.StringWriter();
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
GridView grd = new GridView();
grd.DataSource = EntityDataSource1;
grd.DataBind();
grd.RenderControl(htmlTextWriter);
Response.Write(stringWriter.ToString());
Response.End();
1- get dataGrid object with data.
2- create object of HtmlTextWriter.
3- try to write the Grid using HtmlTextWriter in you response.
as the following in button_Click event of any other location you want to perform this action.
string attachment = "attachment; filename=RegisteredUsers.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Charset = "UTF-8";
Response.ContentType = "application/vnd.ms-excel";
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
System.IO.StringWriter stringWriter = new System.IO.StringWriter();
HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
GridView grd = new GridView();
grd.DataSource = EntityDataSource1;
grd.DataBind();
grd.RenderControl(htmlTextWriter);
Response.Write(stringWriter.ToString());
Response.End();
التسميات:
C#
2009/01/28
Oracle connection string for C#
using System;using System.Data;
using System.Data.OleDb;
class OleDbConnectionOracle
{
public static void Main()
{
string connectionString = "provider=MSDAORA;data source=ORCL;user id=SCOTT;password=TIGER";
OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);
OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();
myOleDbCommand.CommandText = "SELECT empno, ename, sal FROM emp WHERE empno = 7369";
myOleDbConnection.Open();
OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();
myOleDbDataReader.Read();
Console.WriteLine("myOleDbDataReader[\" empno\"] = " + myOleDbDataReader["empno"]);
Console.WriteLine("myOleDbDataReader[\" ename\"] = " + myOleDbDataReader["ename"]);
Console.WriteLine("myOleDbDataReader[\" sal\"] = " + myOleDbDataReader["sal"]);
myOleDbDataReader.Close();
myOleDbConnection.Close();
}
}
التسميات:
C#
Subscribe to:
Posts (Atom)