Data Controls :: How To Export GridView Bind With SQLDataSource To PDF
Oct 2, 2012how to export girdview populated with SQLDataSource to pdf file ??
View 1 Replieshow to export girdview populated with SQLDataSource to pdf file ??
View 1 RepliesI have been trying some things and got stuck in problem.
I created a Gridview and SQLDataSource in designer and a on Button event executed the following Code
GridView1.DataSourceId="SQLDataSource";
It worked Fine and populated the Grid View.
But when i Decided to PRogramatically Create SQLDataSource ANd populate the Gridview by the following code
SqlDataSource fd = new SqlDataSource();
fd.ConnectionString = "<%$ ConnectionStrings:ConnectionString %>";
fd.SelectCommand="select * from [Department]";
GridView1.DataSourceID = "fd";
it didnt work. And Gave the following Error
The DataSourceID of '' must be the ID of a control of type IDataSource...
I am using Visual Web Developer (VWD)and I dragged in i.e created a Gridview. In the codebehind of the page, I will like to declare an sqldatasource and get data from a database using the sqldatasource and then bind the sqldatasource to the Gridview. PS: I know how to drag-in an sqldatasource and attach it to the gridview using VWD but this time, I want to do this declaratively in the codebehind.
View 3 RepliesI got a Buisness Logic Layer where i have a function that returns a DataTable, how can I bind it to SqlDataSource or ObjectDataSource Snippet of BLL
[Code]....
[code]....
aspx.vb file
Dim dt As DataTable = Nothing
dt = ReturnCarsInStock.GetCarsInStockComplete(procBrand, procMode)
I have a code that read all data from sqldatasource and store it in exel file. my problem is,when the program run when i click on button,the message pop up to open or save, so by click on open or save we can either save it in exel file or open and look in exel file.
i want withought poping any message,it store the file directly to the specific folder without infomring the user.
here is my code
string attachment = "attachment; filename=Contacts.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
I have a dropdownlist that's being populated from a SQL datasource. I would also like to have a tooltip for each dropdownlist list item on mouse over. I found the example below which adds a title attribute for each list item using the listitem text as a tooltip but I want to make the title/tooltip value another field in the database. In other words,
item.Attributes.Add("title", someotherdatabasefield);
The end result would be something like this where the text for 'title' comes from the database
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem Text="CompanyName1" Value="1" title="a really great company" />
<asp:ListItem Text="CompanyName2" Value="2" title="a really bad company" />
</asp:DropDownList>
[Code]....
I have downloaded the ajax control tool kit but i cant make the combobox display data from the db.
From what i read from online resources , it seems my syntax is correct...but data is not displayed!
Here some markup from my page
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:ComboBox ID="Supplier" runat="server" style="margin-left: 57px; display: inline;"
Width="245px" DataSourceID="dsSuppliers" DataTextField="SupplierName"
DataValueField="ID" MaxLength="0" AutoCompleteMode="SuggestAppend"></asp:ComboBox>
<asp:SqlDataSource ID="dsSuppliers" runat="server"
ConnectionString="<%$ ConnectionStrings:unrafpl %>"
SelectCommand="SELECT [ID], [SupplierName] FROM [tblSuppliers]">
</asp:SqlDataSource>
i am facing a minor problem but can't find out its syntaxi have listview, and inside the template i have 2 labels, in design time i bind 1 label to one column thatis 'type' and depending upon this type i want to bind other labels to different columnsif type is question than 2 label will have to show data of question columnif type is job than 2 label will have to show data of job, so on........how to accomplish this,in databinding event handler i can check the value of typebut i want to know the syntax of binding 2 label in run time, with different fields using EVAL
View 3 RepliesI am now trying to bind data from SqlDataSource into a textbox, but the problem that I face is that my DataSource only return a single row. So i don't place my textbox inside any DataView or listview.
Below is my datasource:
[Code]....
So can I possibly bind the data into the textbox?
Is it possible to assign the SQLDataSource.Select results to the LinqDataSource results ?
View 1 RepliesI have a listbox controll and i want to bind it with an SqlDataSource.SqlDataSource must be declared in the code behind but i don't know where declare it(page init,page load...)and how to add sql parameter dynamically (parameters are the selected values of listbox, so they are multiple).
View 2 RepliesHow can I bind radio buttons to an sqldatasource for update ?
View 2 Repliesi designed a gridview to update, delete the records using sqldatasource, (there is no code in my aspx.cs file) but i dont know how to add the new row the gridview. so that if the table is empty then i cant add / update / delete the data.
how to Add new record on gridview using SQLDatasource without any code behind code?
i want delete record from gridview(delete template feild) but i have a error!
View 1 RepliesIs it possible to use a SQLDataSource to populate a gridview but not use the SQLDataSource for Updating?
I wanted to add the update code in the Gridview_RowUpdating event since it is a complex update I need to do.
I get this message when i click the update button
Updating is not supported by data source 'SqlDataSource1' unless UpdateCommand is specified.
I have textbox that searches for first or last name. Result show in gridview. But when add value in text box and push my button Find nothing happen. Here code:
aspx:
........
<asp:GridView runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataKeyNames="MobileNum"[code]....
I want to sorting the gridview. I am using stored procedure currentlyHow can I put the sorting functions?
protected void populateItem()
{
string itemQuery = "usp_GetStockList";
[code]...
In my asp.net+vb code +sql database web. i have three sqldatasource in on eweb page. i am willing to add radiobutton list for selection of sqldatasourec and show data in gridview.
View 1 Repliesusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
[code]....
my data in gridview4 disappears when i click add to cart it shows no data again i have to pass a query from gridview 3 and then gridview 4 appears and then again if i click on add to cart in gridview 4 it shows no data.
I am using Ajax ConfirmButtonExtender Control in GridView for Deleting the Record. I am also Exporting the GridData to Excel using Render Method. But when i click on the Export Button, i am getting below error Extender control 'confirmID' is not a registered extender control. Extender controls must be registered using RegisterExtenderControl() before calling RegisterScriptDescriptors(). Parameter name: extenderControl
View 1 RepliesI am exporting gridview to excel.I have below code to generate excel sheet.I have used Datagrid to populate grid using SqlDataSource. below code generate excel sheet when used SqlDataSource.
Code:
GridView1.AllowPaging = false;
GridView1.GridLines = GridLines.None;
GridView1.DataBind();
ChangeControlsToValue(GridView1);
Response.ClearContent();
[code]...
but when i populate grid without SqlDataSource, in that case 'gridView.Controls.Count' stores 0 value and excel sheet contains zero(0) record. how to modify this code without using SqlDataSource.
Can we export a gridview with a child gridview to excel?
View 1 Repliesin my asp.net+access web code in vb. There is three labels named (tata.text,tvs.text,msu.text) is there any option on clicking on the label named tata.text the data pertaining to tata be displayed in a gridview in another page or a popup display in same page.
View 1 RepliesI have a gridview and a SQLDataSource control. In my gridview I have 2 commandfields "Edit" and "Delete"
The "Edit" command field works as expected. Using the "Delete" command field I get the error below.
Server Error in '/DataControls' Application.
The DELETE statement conflicted with the REFERENCE constraint "FK__titleauth__au_id__0CBAE877". The conflict occurred in database "pubs", table "dbo.titleauthor", column 'au_id'. The statement has been terminated.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: The DELETE statement conflicted with the REFERENCE constraint "FK__titleauth__au_id__0CBAE877". The conflict occurred in database "pubs", table "dbo.titleauthor", column 'au_id'. The statement has been terminated.
Source Error:
[Code]....
Stack Trace:
[Code]....
I have gridview+sqldatasource. In gridview i have button DELETE. But i want on click this button for some rows execute DELETE command other rows UPDATE. I did:
[Code]....
@index - DeleteParametrs in sqldatasource.
But DELETE works and DELETEVIRTUAL doesn't. Then i insert sourceMain.Delete() in rowcommand after sourceMain.DeleteCommand ... But it's doesn't help me.