User Profile & Activity

ca Member
Page
of 5
Posted: September 29, 2009 1:56 AM

can you please give me a complete code of example, in which i can populate the webgrid from database using backend C# programming.

        string condition = Request.QueryString["cond"];        string connectString = ConfigurationManager.ConnectionStrings["ConnectionString2"].ConnectionString;        OleDbConnection Connection1 = new OleDbConnection(connectString);        OleDbCommand Cmd = Connection1.CreateCommand();
        Cmd.CommandType = CommandType.Text;
        Cmd.CommandText = "SELECT MENU_PARAMETER_8 FROM ADM_MENU WHERE MENU_ID='" + condition + "'";
        Cmd.Connection.Open();
        OleDbDataAdapter da = new OleDbDataAdapter(Cmd);
        OleDbCommandBuilder comBuilder = new OleDbCommandBuilder(da);
        DataTable dt = new DataTable();
        da.Fill(dt);
        if (dt.Rows.Count > 0)
        {
            foreach (DataRow row in dt.Rows)
            {
                query = row[0].ToString();
            }
        }
        Cmd.Connection.Close();
        OleDbCommand Cmd1 = Connection1.CreateCommand();
        Cmd1.CommandType = CommandType.Text;
        Cmd1.CommandText = query;
        Cmd1.Connection.Open();
        OleDbDataAdapter da1 = new OleDbDataAdapter(Cmd1);
        OleDbCommandBuilder comBuilder1 = new OleDbCommandBuilder(da1);
        DataTable dt1 = new DataTable();
        da1.Fill(dt1);
        WebGrid1.DataSource = dt1;
        WebGrid1.RetrieveStructure();
        WebGrid1.DataBind();
        Cmd1.Connection.Close();

 

this is the code i have used. Here i am getting the data displayed on the grid. But with this any of the functionality of grid sucha as grouping , virtual load, filtering etc are not working.


please reply me with example code and let me know how can enable features of your webgrid on that(like virtual load).

Posted: September 28, 2009 9:33 AM

hello,


your solution doesnt solved the problem.


please let me know is there any way to disable that kind of error message....

i have solved this problem by


        WebGrid1.RootTable.AllowAddNew = ISNet.WebUI.WebGrid.AddNew.No;

        WebGrid1.RootTable.AllowEdit = ISNet.WebUI.WebGrid.Edit.No;

        WebGrid1.RootTable.AllowDelete = ISNet.WebUI.WebGrid.Delete.No;



thank you all

Posted: September 14, 2009 6:18 AM

thank you for the reply.


how can i get the  HyperlinkFormatString of the selected link in the javascript.

Means i am running the javascript function when click on the hyperlink. Inside that i want to get the HyperlinkFormatString.


thanks and regards 

ca




Posted: September 13, 2009 12:43 AM

hi,


ok.


also i have tried some button event to catch the selected node. But it seems not working.

below is the code,  i have used.




 protected void Button1_Click(object sender, EventArgs e)

    {

          Label1.Text = WebTreeView1.SelectedNode.ToString();

    }

Posted: September 9, 2009 4:16 AM

thank you handy..


the tree is working for me... but i have some small problem...

if i give the image for the tree node, it working but the expand image property is not working

here is the code below


 protected override void OnInitComplete(EventArgs e)

    {

        base.OnInitComplete(e);

        WebTreeViewNode rootNode = new WebTreeViewNode();

        rootNode.Name = "REPORTS";

        rootNode.Text = "REPORTS";

        rootNode.Image = "~/images/folder-close.jpg";

        rootNode.ExpandedImage = "images/folder-open.jpg"; // This is not working

        rootNode.Value = "report";

        WebTreeView1.Nodes.Add(rootNode);



        WebTreeView1.EnableLoadOnDemand = true;

        WebTreeView1.AllowNodeEditing = AllowEditing.Yes;

        WebTreeView1.AutoPostBackSettings.OnNodeEdit = true;


    }

Posted: September 9, 2009 4:12 AM

thanks .... i got solution.

All times are GMT -5. The time now is 7:38 AM.
Previous Next