Tuesday, January 3, 2012

Binding Data to a GridView using SPDataSource Object.

SPDataSource source = new SPDataSource();
                source.DataSourceMode = SPDataSourceMode.List;
                source.SelectCommand = "<Query><OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy></Query>";
                source.InsertParameters.Add("ListName", "Tasks");
                source.InsertParameters.Add("Webs", Objweb.Url);
                this.Controls.Add(source);
                ddlStatus.DataTextField = "Title";
                ddlStatus.DataValueField = "Title";
                ddlStatus.DataSource = source;
                ddlStatus.DataBind();

No comments:

Post a Comment