C# - How To Connect GridView DataSource Over Webpart Class

Mar 1, 2010

i try to make myGridView Companent via using WebPArt you know it :

using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using System.Web.UI;
namespace MyGridView
{
public class MyGridView : WebPart
{
GridView gv;
protected override void CreateChildControls()
{
gv = new GridView();
gv.CssClass = "tablestyle";
this.Controls.Add(gv);
}
}
}

i added this GridView on Toolbox. Every Thing is ok . İ want to add my own CSS design to my GridView. But if i drow this gridView from toolbox to aspx page. if i bind my datasource ; Datasource is not show himself.

Like that Main program:

protected void Page_Load(object sender, EventArgs e)
{
LoadData loaddata = new LoadData();
DataTable dt = loaddata.LoadSQL("conn", "sp_GetAllCategory");
MyGridView1.datas.... -----> i can not see DataSource why?
}

i want to see My GridView DataSource. if i write Binding datasource. MyGridView1.DataSource -----> i can not see DataSource why?

View 1 Replies


Similar Messages:

Web Forms :: Access Aspx Page Control In Webpart Class?

Jan 18, 2010

i have a hidden textbox in my aspx page. The aspx page also has a masterpage in the <% @Page> directive.

<input type="hidden" runat="server" name="txtType" id="txtType" />&nbsp;
actually in aspx.cs i am getting txtType.ClientID="ctl00_MainHeaderContent_txtType"

I have a webpart in a webpart zone in this aspx page. In the webpart CreateChildcontrols() I need to access this hiddenTextbox value. I am able to access it as

string TxtValue = this.Page.Request.Form["ctl00_MainHeaderContent_txtType"];

But instead of hardcoding I want to access as a control in the page or form. How can I do that I want to do as looping through the controls in the page but Page.Controls.Count gives 1 and that is MasterPage. How can I get the entire controls in the page and loop through and find the hidden textbox. I also tried as string TxtValue = this.Page.Request.Form["<%=txtType.ClientID%>"] in CreateChildControls() of the webp[art. But could not access hidden textbox like this.

View 2 Replies

DataSource Controls :: Connect Gridview To Database?

Apr 21, 2010

I've created a SQL Server Express database to use with a program I'm working on in Visual Web Developer 2008. The connection works fine according to the Add connection-wizard in VWD. However there's a problem when I try to select data from the database and present the data in a gridview. The error message says that the gridview isn't connected to the database. The gridviews DataSource ID (source-mode) is the same as the name of the database. In design-mode, when I try try configure the datasource I get to a point where I have to configure the select statement, but I just want the connection to work in a way that let's me write the sql-statements in the aspx.cs-file.

View 4 Replies

C# - Reload The Information Of The Sharepoint 2007 Webpart After A Button Is Clicked From Another Webpart?

Dec 29, 2010

I am new in sharepoint development. I have 2 webparts attached on a page. The first webpart (MyTestingWebpart1) basically it does only inserting of data and the other webpart (MyTestingWebpart[2]) displays the records from the database. Now my problem is when I try to click on the save button, somehow I don't know how to refresh the webpart that displays the newly inserted record. Is this possible?

I have added a query at the page load event of MyTestingWebPart[2]. Both of the webparts attached are web user controls.

View 2 Replies

Web Forms :: Deployed Project Not Showing Webpart Verb Tool Bar (minimize, Close Buttons Of WebPart)

Jan 4, 2011

I am just started development in ASP.NET.

I have created one sample application for WebParts. It is working fine when I run it from Visual Studio or local environment.

But when, I have publish file in IIS virtual directory (in my PC or same PC) at that time it is stop showing Verb tool bar (minimize, close buttons of WebPart).

View 1 Replies

DataSource Controls :: Detect Database Connection And Setup New Connectikonstring From ASP.NET WebPart?

Jun 14, 2010

am writing a series of WSS/MOSS webparts amongst which one will need to detect the current SQL Server database connection, prompt the user to setup a new connectionstring, and fire appropriate stored procedures to create a new database if needed. The user needs to be presented a textbox or label control with the current database connection. I've never had to detect current database connection, what methods do I call for this? If the desirable connection is not present, the web application needs to prompt the user to make a new database. The user really won't make the database, they simply need to click the command button which will fire the stored procedure to create the database.

View 1 Replies

How To Set Datasource Gridview To Linq In A Class Function

Aug 4, 2010

i have my page who load my gridview as: GRW.datasource=className.List2(2);i have this function in my class

[Code]....

it returns an error , cannot convert single result to queryable!! in " blo= DB.MarketList(TypeID);"

View 10 Replies

GridView In Webpart With Multiple Filters?

Apr 12, 2010

I'm currently working on a highly configurable Database Viewer webpart for WSS 3.0 which we are going to need for several customized sharepoint sites. but i fear it's necessary to recap the whole issue. As background information and to describe my problem as good as possible, I'll start by telling you what the webpart shall do:

Basically the webpart contains an UpdatePanel, which contains a GridView and an SqlDataSource. The select-query the Datasource uses can be set via webbrowseable properties or received from a consumer method from another webpart. Now i wanted to add a filtering feature to the webpart, so i want a dropdownlist in the headerrow for each column that should be filterable. As the select-query is completely dynamic and i don't know at design time which columns shall be filterable, i decided to add a webbrowseable property to contain an xml-formed string with filter information.

So i added the following into OnRowCreated of the gridview:

void gridView_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (e.Row.Cells[i].GetType() == typeof(DataControlFieldHeaderCell))
{
string headerText = ((DataControlFieldHeaderCell)e.Row.Cells[i]).ContainingField.HeaderText;
// add sorting functionality
if (_allowSorting && !String.IsNullOrEmpty(headerText))
{
Label l = new Label();
l.Text = headerText;
l.ForeColor = Color.Blue;
l.Font.Bold = true;
l.ID = "Header" + i;
l.Attributes["title"] = "Sort by " + headerText;
l.Attributes["onmouseover"] = "this.style.cursor = 'pointer'; this.style.color = 'red'";
l.Attributes["onmouseout"] = "this.style.color = 'blue'";
l.Attributes["onclick"] = "__doPostBack('" + panel.UniqueID + "','SortBy$" + headerText + "');";
e.Row.Cells[i].Controls.Add(l);
}
// check if this column shall be filterable
if (!String.IsNullOrEmpty(filterXmlData))
{
XmlNode columnNode = GetColumnNode(headerText);
if (columnNode != null)
{
string dataValueField = columnNode.Attributes["DataValueField"] == null ? "" : columnNode.Attributes["DataValueField"].Value;
string filterQuery = columnNode.Attributes["FilterQuery"] == null ? "" : columnNode.Attributes["FilterQuery"].Value;
if (!String.IsNullOrEmpty(dataValueField) && !String.IsNullOrEmpty(filterQuery))
{
SqlDataSource ds = new SqlDataSource(_conStr, filterQuery);
DropDownList cbx = new DropDownList();
cbx.ID = "FilterCbx" + i;
cbx.Attributes["onchange"] = "__doPostBack('" + panel.UniqueID + "','SelectionChange$" + headerText + "$' + this.options[this.selectedIndex].value);";
cbx.Width = 150;
cbx.DataValueField = dataValueField;
cbx.DataSource = ds;
cbx.DataBound += new EventHandler(cbx_DataBound);
cbx.PreRender += new EventHandler(cbx_PreRender);
cbx.DataBind();
e.Row.Cells[i].Controls.Add(cbx);
}
}
}
}
}
}
}

GetColumnNode() checks in the filter property, if there is a node for the current column, which contains information about the Field the DropDownList should bind to, and the query for filling in the items.

In cbx_PreRender() i check ViewState and select an item in case of a postback. In cbx_DataBound() i just add tooltips to the list items as the dropdownlist has a fixed width.

Previously, I used AutoPostback and SelectedIndexChanged of the DDL to filter the grid, but to my disappointment it was not always fired. Now i check __EVENTTARGET and __EVENTARGUMENT in OnLoad and call a function when the postback event was due to a selection change in a DDL:

[Code]....

When i have two or more filters set which return zero rows, and i change back one filter to something that should return rows, the gridview remains empty (although the pager is rendered). I have to completly refresh the page to reset the filters. When debugging, i can see in the overridden CreateChildControls of the grid, that the base method indeed returns > 0, but anyway.the gridView.RowCount remains 0 after databinding. Anyone have an idea what's going wrong here?

View 1 Replies

Web Forms :: Gridview Inside Webpart In C#?

Jan 1, 2010

I am trying to read the data from XMLDataSource into a gridview (in asp.net). It works when I perform below logic:

Dim ds As New DataSet()
ds.ReadXml(Server.MapPath("LoadData.xml"))
GridView1.DataSource = ds.Tables(0)
GridView1.DataBind()
and I hardcoded the resultant hyperlinks inside the GridView with some name using the following exp: (and it works).....

But when i embed the griview inside a webpart , configure the datasource, I am not able to read the data from the XMLDataSource. I get the following error: The DataSourceID of "GridView1" must be the ID of a control of type IDataSource. A control with ID "XMLDataSource1" could not be found.

View 3 Replies

C# - How To Connect UserControl To A Datasource

Feb 24, 2011

I'm trying to find a way to Databind a usercontrol to a datasource (an
ObjectDataSource in my case) like in the case below :
<uc1:AutoComplete ID="autoComCities" runat="server"
DataSourceID="objCitiesDS" DataValueField="Id" DataTextField="Name" />

View 1 Replies

DataSource Controls :: How To Connect To Mysql With C#

Apr 23, 2010

oledbCon.ConnectionString = "Provider=MySqlProv; Data Source=localhost; Initial Catalog = AnymoreComputers; User id=WeakUser2;Password=1234";

my site is working and running wrote in c# and mssql 2005,

now i want to make it run with mysql.....i converted all my data base...and created the same users (same names)

anc copied all to my sql .

the question is how do i connect to mysql wit c# ......

my regular connection for mssql :

oledbCon.ConnectionString = "Provider = SQLOLEDB.1; DATA Source = (local); Initial Catalog = test1; Integrated Security = SSPI; User ID=WeakUser2;Password=1234";
the connection to mysql :
oledbCon.ConnectionString = "Provider=MySqlProv; Data Source=localhost; Initial Catalog = test1; User id=WeakUser2;Password=1234";

this connection doesnt works ... where is my mistake ? what hsould i do ... ?

and this is the error ig get when i run my solution :"The ConnectionString property has not been initialized."

i am using OleDbDataAdapter and dataSet ....

View 3 Replies

DataSource Controls :: How To Connect To Database

Feb 15, 2010

There is any another way to connect SQL Server database instate of Server Explorer i ASP.Net MVC .If yes tell me How?

View 3 Replies

DataSource Controls :: Connect Sql Server Db?

May 24, 2010

i would like to ask about the connect to db using sqldataadepter code as below:

public static DataTable GetTest()
{
DataTable dt = new DataTable();

[code]...

View 3 Replies

DataSource Controls :: Connect To The SqlServer In Pc1 From Pc2?

Apr 11, 2010

we have local net in our company.(we dont have win server.)

now i want to know how i can connect to the sqlServer in pc1 from pc2?

View 1 Replies

DataSource Controls :: Can't Connect To Database?

Mar 23, 2011

I'm new here and I'm in dire need of help. Been trying to solve a problem for hours now.Here's what I wanted to do: I added a table 'tblProductCat' in the webform and I intend to populate the table with VB codes as shown below

[Code]....

What am I doing wrong here? I really can't figure this out. There was a time when, instead of that exception handling message appearing, a yellow box that states something between the lines of 'offline' and 'check your root folder for *something*' or something like that.

View 1 Replies

DataSource Controls :: Connect To DB That Is Not On Network?

Mar 24, 2010

Is there a way to connect to a db that is not on your network!?!? How would I do that?

Using VS 2008.

View 2 Replies

DataSource Controls :: Can't Connect To Instance On Server With IIS 6.0

Mar 17, 2010

I'm running SQL Express 2005 on an SBS 2003 Standard Server and I keep getting this error back.A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 28 - Server doesn't support requested protocol)

I've uploaded my project to this same server, and I've so far checked that TCP/IP has been enabled for this instance, I've checked the IPs are relevant, I've checked that the connection string is correct, and I've even set a dynamic port number as I've noticed that SBS runs 2005 databases for Sharepoint and Monitoring.

Interestingly enough, I can connect to this instance via Visual Studio on my remote machine, and SSMSE and also via SSMSE on the server as well?The connection string i'm running with is:

Data Source=localhostVDSSQL;Initial Catalog=myDB;Persist Security Info=True;User ID=SA;Password=***

View 23 Replies

DataSource Controls :: Unable To Connect With SQLserver ?

May 14, 2010

i have been trying to connect to SQLserver from ASP.net web developer in an n-tier architecture.But it shows this error in conncetion


A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

View 3 Replies

DataSource Controls :: How To Connect To Multiple Databases

Jun 8, 2010

i want to know how to connect to multiple databases in sql from our asp.net code??

View 4 Replies

DataSource Controls :: Is There A Way To Connect Two Entities Together In One New Entity

May 22, 2010

And not doing a View that connect two tables ?Is there a way to connect two entities together in one new entity?

View 1 Replies

DataSource Controls :: How To Connect To Sqlserver (cubes) Using C#

May 8, 2010

i am new to this cubes concept in sqlserver . i need to connect to cubes and and query and get an result and display that result in grid view

how to connect to an cube, articles on it, code any thing

View 1 Replies

DataSource Controls :: Cannot Connect To SAEID-PCSQLEXPRESS?

Sep 8, 2010

I have use vs.net 2008 and sql erver 2008.When I wanna connect to sqlExpress in Sql Server Managment Studio 2008 this error is shown:Cannot connect to SAEID-PCSQLEXPRESS.A network-related or instance-specificerror occurred while establishing a connectionto SQL Server. The server was not found or was notaccessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error LocatingServer/Instance Specified) (.Net SqlClient Data Provider)
In SqlServer Configuration Manager when I want start SqlExpress service an error is shown to me that cann't start the service.

View 4 Replies

DataSource Controls :: Connect SQL Server Through IP Address

Mar 18, 2010

I want to connect Sql server which is on remote mechine by IP adress. at present i able to connect sql sever which is on local machine using followning code:

SqlConnection con =
new
SqlConnection("Data Source=HCL-LAPTOP;Initial Catalog=databasename;User id=sa;Integrated Security=True");

View 4 Replies

DataSource Controls :: Connect To Database On A Different Domain?

Jan 26, 2010

I'd like to connect to a database on a different domain. I've done some search and people say to add a connectin using an enterprise manager? Where can I find sql enterprise manager? On msn website, they only show things about sql enterprise manager for sql 2000. Is this a tool only included in sql 2000?

View 4 Replies

DataSource Controls :: Can Not Connect To Local Database?

Jan 13, 2010

I had a database on a development server of which I am not the owner. The connection string was:

Dim MM_cnnTraining_STRING
MM_cnnTraining_STRING = "Provider=SQLOLEDB.1;Password=xxx;Persist Security Info=True;User ID=xxx;Initial Catalog=Training;Data Source=xxx"

I copied this database to my local machine, In services MSSQL is set to logon with my computer username and password, I have no idea if this affects anything.Also the local database which I can view in MSSQL Server Management Studio, I can connect by Windows Authentication only. The database copied there seems to have maintained the same permissions.Im completely confused. I finally was able to copy to my local machine but now can not connect. I am using dreamweaver, but using the connection string above.

View 7 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved