CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.web_parts_and_personalization Tags:
Item Type: NewsGroup Date Entered: 1/10/2008 6:44:36 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 5 Views: 32 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
6 Items, 1 Pages 1 |< << Go >> >|
shuklaanupam
Asp.Net User
problem with grid view1/10/2008 6:44:36 AM

0/0

hi,

    i m creating a grid view control in web part.. for that i wrote the following code, but grid does't appears.. plz help me out...

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.WebPartPages;
using System.Drawing;
using System.Data.SqlClient;
using System.Data;

namespace _Test_
{

    /// <summary>
    /// Description for List.
    /// </summary>
    [DefaultProperty("Text"),
        ToolboxData("&lt;{0}:List runat=server></{0}:List>"),
        XmlRoot(Namespace = "_Test_")]
    public class List : Microsoft.SharePoint.WebPartPages.WebPart
    {
        GridView Gridview = new GridView();
              // [Browsable(true),
        //    Category("Miscellaneous"),
        //    DefaultValue(defaultText),
        //    WebPartStorage(Storage.Personal),
        //    FriendlyName("Text"),
        //    Description("Text Property")]
        //public string Text
        //{
        //    get
        //    {
        //        return text;
        //    }

        //    set
        //    {
        //        text = value;
        //    }
        //}

        ///// <summary>
        /////	Constructor for the class.
        /////	</summary>
        //public List()
        //{
        //}

        
               
       
        protected override void CreateChildControls()
        {
            this.Controls.Clear();

            //gridview properties
            //GridView Gridview = new GridView();
            Gridview.ID = "grid";
            Controls.Add(Gridview);
            Gridview.BorderColor = ColorTranslator.FromHtml("#000080");
            Gridview.AutoGenerateEditButton = true;
            Gridview.AutoGenerateEditButton = true;

           BoundField gridColumn = new BoundField();
            gridColumn.DataField = "Name";
            gridColumn.HeaderText = "Name";
            Gridview.Columns.Add(gridColumn);

            gridColumn = new BoundField();
            gridColumn.DataField = "List";
            gridColumn.HeaderText = "Todolist";
           Gridview.Columns.Add(gridColumn);
           this.Controls.Add(Gridview);
           DataSet ds = new DataSet();
           string select = "select *from Todolist";


           SqlConnection conn = new SqlConnection("server=IE10DT2K3955ZL1;Initial Catalog=anupam;Integrated Security=True;");


           try
           {
               conn.Open();

               SqlDataAdapter da = new SqlDataAdapter(select, conn);

               da.Fill(ds, "Todolist");
               Gridview.DataSource = ds;
               Gridview.DataBind();
               conn.Close();
               //base.OnPreRender(e);
           }
           catch
           {
               Label lb1 = new Label();
               lb1.Text = "Data can't displayed";
               Console.WriteLine("" + lb1);
           }




           // panel properties
            Panel mainPanel = new Panel();
            mainPanel.ID = "panel";
            Controls.Add(mainPanel);
            mainPanel.BackColor = Color.AliceBlue;
            mainPanel.Height = 100;
            mainPanel.Controls.Add(Gridview);
            
            
            //base.CreateChildControls();
        }

    }
}
i m using sql server and the database is on server side and using windows authentication mode..  i m able to only blank panel with aliceblue color background...
telll me where i need to change or what's wrong here..
 
 
 
 
siva_sm
Asp.Net User
Re: problem with grid view1/10/2008 12:11:18 PM

0/0

Set the DataMember property of the GridView to "ToDoList" (the name of the DataTable filled by the data adapter) before binding.

shuklaanupam
Asp.Net User
Re: problem with grid view1/10/2008 1:19:58 PM

0/0

thnx...

u mean to say something..

Gridview1.DataMember= "TodoList";

set this before

Gridview1.DataBind(); this line...

i did that... but not working.. anything else u can suggest then plz let me know..

 

 

siva_sm
Asp.Net User
Re: problem with grid view1/10/2008 2:27:29 PM

0/0

Also, this.Controls.Add (panel1) at the end?

shuklaanupam
Asp.Net User
Re: problem with grid view1/11/2008 8:56:04 AM

0/0

thnx.. got that...
shuklaanupam
Asp.Net User
Re: problem with grid view1/11/2008 8:59:30 AM

0/0

hi.. i got grid view with edit button in that.. now i want to insert a new row from the grid view.. plz tell this can be done... and what to write for update command..

thnx....

6 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

problem with grid view - ng.asp-net-forum.web_parts_and_personalization ... problem with grid view, > ROOT > NEWSGROUP > Asp.Net Forum > general_asp.net. ... Problem on Using Data Grid View on VB.Net - Microsoft Technical ...
Problem with textboxes in headertemplate of gridview, events not fired ... Problem with textboxes in headertemplate of gridview, events not fired, > ROOT > ... Dynamically Templated GridView with Edit, Delete and Insert Options ...
Problem with GridView's RenderControl - ASP.NET Forums I just used GridView.RenderControl() method. However I got a message that said GridView Type Control must be put in Form tag with runat=server. ...
Row index problem with gridview. - ASP.NET Forums ASP.NET Forums " General ASP.NET " Data Presentation Controls " Row index problem with gridview. ... Row index problem with gridview. Last post 08-02-2008 7:19 ...
ASP.NET Tutorials: GridView Hidden Column Problem (And Two Common Solutions) Explains how to simulate hidden column in GridView control. ... Because the event is called after the data is bound to the grid...
p2p.wrox.com Forums - Problem in Gridview Cell p2p.wrox.com Forums - problem in gridview cell ... View our list of code downloads. New Topic Reply to Topic Printer Friendly. Author ...
problem with GridView problem with GridView. microsoft.public.dotnet.framework.aspnet. 6 Sep 2006 7:07 AM ... this is the source of my GridView control ...
p2p.wrox.com Forums - Problem with gridview update. p2p.wrox.com Forums - problem with gridview update. ... View our list of code downloads. New Topic Reply to Topic Printer Friendly. Author ...
ASP.NET - ASP.NET And VB.NET: Problem With GridView's "disabled" B ... ASP.NET - ASP.NET And VB.NET: Problem With GridView's "disabled" B. Get help with this and thousands of other programming and web development topics at DreamInCode.net.
Gridview validation problem - MSDN Forums ... the GridView is linked to the CompareValidator routine (try "View Source" when ... I was posting the whole grid (to cut down on the postbacks), rather than on a ...



 
All Times Are GMT