This post is a compiled version of Steve Cavanagh's blog post on How To: Spell Check an InfoPath form displayed via XmlFormView. Many are not able to follow Steve's instructions due to lack of details. See below a downloadable zip of all changes need installed for your InfoPath Spell Checker.
File Contents:
- CustomSpellCheckEntirePage.js - This is a customized SpellCheckEntirePage.js which includes changes outlined in Steve's post above.
- FormServer.aspx - Note that this will replace the exisitng FormServer.aspx - this file acts like a masterpage for all infopath forms. So this change will add the spellchecker to all infopath forms in the sharepoint farm. Only thing i changed here is to add the 'Spell Check' link before and after the form.
- ReadMe.rtf - Contains instructions where to copy the files to in your MOSS WFE server.
I have been researching about this the whole morning and never found a straight forward answer. I will not be giving codes on this post BUT I will however encourage you not to do this for 3 good reasons:
- Ask yourself again if you really need to do this, and why. Gridviews are only graphical representations of set(s) of data from databases and/or datasets. So, ofcourse, if you wanted to add a row to your gridview, add it up on the table on your database and use the DataBind() method to bind the grid again from its data source.
- Let the database do its job. It is easier to handle data transactions on the database rather than in codes.
- For example, you've managed to get your code working to insert into a gridview dynamically, what next? Would you want to overwrite the database table with you gridview? I am not exactly sure if you can do this but this is a very bad programming practice.
SqlDataAdapter
Use this data adapter object to bind SQL data sources.
Using SqlDataAdapter Object
|
Using System.Data.OleDb; // do not forget your namespace
------------------------------
|
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(query, conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
conn.Close();
OleDbDataAdapter
Use this data adapter object to bind data sources that uses OLE DB drivers such as MS Access databases.
Using OleDbDataAdapter Object
|
Using System.Data.OleDb; // do not forget your namespace
------------------------------
|
OleDbConnection conn = new OleDbConnection(connectionString);
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = new OleDbCommand(query, conn);
DataSet ds = new DataSet();
adapter.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
conn.Close();
SqlDataReader
Use this datareader object to bind SQL data sources.
Using SqlDataReader Object
Using System.Data.SqlClient; // do not forget your namespace
------------------------------
SqlConnection conn = new SqlConnection(connectionString);
conn.Open();
SqlCommand comm = new SqlCommand("select * from [My_Table]",conn);
comm.CommandType = CommandType.Text;
SqlDataReader dr = comm.ExecuteReader();
while (dr.Read())
{
TextBox1.Text = (string)dr["info"].ToString();
//datareader object accepts 2 overloads - a string header name or an int header index
}
dr.Close();
conn.Close();
|
OleDbDataReader
Use this datareader object to bind data sources that uses OLE DB drivers such as MS Access databases.
Using OleDbDatareader Object
|
Using System.Data.OleDb; // do not forget your namespace
------------------------------
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
OleDbCommand comm = new OleDbCommand("select * from [My_Table]",conn);
comm.CommandType = CommandType.Text;
OleDbDataReader dr = comm.ExecuteReader();
while (dr.Read())
{
TextBox1.Text = (string)dr["info"].ToString();
//datareader object accepts 2 overloads - a string header name or an int header index
}
dr.Close();
conn.Close();
|