i'm using grid control in DevExpress reports when i set data source dynamically to my grid control its not showing a output, anyone please help me to get.
this is my code
DataTable dtJobOrder = new DataTable();
string DTQuery = #"Select Product from JobOrder";
dtJobOrder = Generic.GetDataTable(DTQuery);
grdspare.DataSource = dtJobOrder;
Probably you already found a way.
You can achieve this by calling PopulateColumns method on grid view.
When you are dynamically set the data source to gridview then you have to set AutoGeneratedColumns to true.
AutoGeneratedColumns = true
Related
I want dynamic hyperlink on each field in a table column from code behind in asp.net, I implement it thus:
table.Append("<td><asp:HyperLink ID='HyperLink1' NavigateUrl='#' runat='server'>" + (string)strNAME + "</asp:HyperLink></td>");
on the field but when I run it there is no link to click. it is not effective. what is the correct way of implementing it?
You need to approach this in a different way. Server side controls cannot be added as string literals, they should be objects. So what you can do is either add it as a server side control:
HyperLink hl = new HyperLink();
hl.ID = "HyperLink1";
hl.NavigateUrl = "#";
hl.Text = (string)strNAME;
TableCell tc = new TableCell();
tc.Controls.Add(hl);
table.Controls.Add(tc);
Or add it as a client side link:
table.Append("<td><a href='#'>" + (string)strNAME + "</a></td>");
Side note: adding table cell to "table" kind of does not make sense because there supposed to be a row, not a table, but I just left your code as is, adjust as needed.
Creating hyperlink from code-behind
HyperLink hlnk = new HyperLink();
hlnk.InnerText = (string)strNAME;
hlnk.ID = "HyperLink1";
hlnk.NavigateUrl = "/test.aspx";
table.Controls.Add(hlnk);
hope it helps
I am populating a dropdownlist in the edititemtemplate of a formview using linq to SQL.
I am getting the data with the below code:
Dim wdc As New WeeklyChecksDataContext
Dim mustchk = (From w In wdc.WeeklyChecks
Where w.DateStamp = Request.QueryString(0)
Select w.musterCheck).FirstOrDefault()
When debugging I can see that the value "Issue" is being assigned to the mustchk variable which is correct.
I am then databinding the dropdownlist as below:
cbMusterReport.DataSource = mustchk
cbMusterReport.DataBind()
When running the web page the value "Issue" is databound to the dropdownlist but each letter of the word "Issue" is databound to its own separate item rather than the word "Issue" being databound as the only item in the dropdownlist. Can't work out what I am missing here. Thanks
You need to put the string in a collection. Try this:
cbMusterReport.DataSource = new String(){ mustchk }
cbMusterReport.DataBind()
Sorry, I've worked it out. Can do it like this
cbMusterReport.Items.Insert(0, New ListItem(mustchk, mustchk))
I'm trying to bind a RadComboBox to an ObjectDataSource whose select method returns a DataSet object. I get an error: "'FieldName', is neither a DataColumn nor a DataRelation for table Table". Just to be sure I'm not crazy, I tried the same with a DropDownList which worked perfectly. I found in Telerik's docs that they support using an ObjectDataSource that returns IEnumerable objects. So, am I correct that the RadControls don't support using ObjectDataSource when it is using a DataSet? Really?
The link you provided points to a different control. See here for the combobox, which is the control in your question title.
The combobox control easily accepts datatable objects from datasets as a source of what to display in the combobox.
Then the combobox control:
Select the GetData method (the only option) and then configure your combobox:
Run:
EDIT:
There seems to be no reason to use a ObjectDataSource if you are already using a dataset and SqlDataAdapter :
DataSet myDataset = new DataSet();
SqlConnection con = new SqlConnection(#"Data Source=J-PC\SQLEXPRESS;Initial Catalog=SO;Integrated Security=True");
SqlDataAdapter adapter = new SqlDataAdapter(#"SELECT TOP (25) Leg_FirstName FROM GRS_Legislator ORDER BY Leg_FirstName", con);
adapter.Fill(myDataset);
RadComboBox1.DataTextField = "Leg_FirstName";
RadComboBox1.DataValueField = "Leg_FirstName";
RadComboBox1.DataSource = myDataset;
RadComboBox1.DataBind();
I have a GridView on an ASP.NET page that I'm trying to bind to an object data source that I've set up to map to a vb object I made which accesses the DB. When I run the page, though, the gridview comes up empty. The ObjectDataSource is definitely returning data. The paging parameters are making it to the underlying object. All the way until I get to the DataBind() call everything seems fine. But the grid comes up empty. Funny thing is, if I use the method that returns all records in the DB, the grid populates just fine. Only when I try to implement custom paging does display no records. I've tried using the wizards, I've tried diagrammatically setting it up and run time. No matter what I do I can't get paged data to display in the grid.
oDatasource = New ObjectDataSource()
oDatasource.EnablePaging = True
oDatasource.TypeName = "tblMessage"
oDatasource.SelectMethod = "GetTblMessageSubset"
oDatasource.SelectCountMethod = "SelectCount"
oDatasource.SelectParameters.Clear()
oDatasource.SelectParameters.Add("strCompanyID", strCompanyID)
oDatasource.SelectParameters.Add("strEmployeeID", strEmployeeID)
oDatasource.StartRowIndexParameterName = "startRowIndex"
oDatasource.MaximumRowsParameterName = "maximumRows"
GridView1.AllowPaging = True
GridView1.PageIndex = 0
GridView1.PageSize = 10
GridView1.PagerSettings.Visible = True
GridView1.EmptyDataText = "No Data........"
GridView1.PagerSettings.Mode = PagerButtons.Numeric
GridView1.AutoGenerateColumns = True
GridView1.DataSource = oDatasource
GridView1.DataBind()
can you check if SelectCount method is returning an Integer as mentioned here?
ObjectDataSource Paging -> no data displayed in GridView
I'm creating a runtime dataset in page load. In this dataset I'm adding columns like that:
CrystalDecisions.CrystalReports.Engine.ReportDocument orpt =
new CrystalDecisions.CrystalReports.Engine.ReportDocument();
DataTable table = new DataTable("DataSet1");
table.Columns.Add("Fname", typeof(System.String));
table.Columns.Add("Lname", typeof(System.String));
table.Columns.Add("Salary", typeof(System.String));
DataRow row = table.NewRow();
row["Fname"] = "Mathew";
row["Lname"] = "Hayden";
row["Salary"] = "5000$";
table.Rows.Add(row);
ds.Tables.Add(table);
orpt.Load(MapPath("CrystalReport3.rpt"));
orpt.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = orpt;
Records are not displayed in CrystalReport3.rpt when I'm going to run the program.
Please tell me how to set these coloums in Crystal Reports 3!
What happens if you move your code from the Page_Load to the Page_Init event handler of the ASP.NET page?
Try to set the AutoDataBind property to "true":
Gets or sets whether automatic data
binding to a report source is used. If
the value is set to True, the
DataBind() method is called after
OnInit() or Page_Init() events.
Another tip: did you try to call the RefreshReport() (or Refresh() in older versions) method of your CrystalReportViewer1 object?
Instead of
orpt.SetDataSource(ds.Tables[0]);
Do
orpt.SetDataSource(ds.Tables["table_name"]);
table_name is the table name you gave for the table