|
Grid can be bound to any Collection type.
You can create a dummy datattable as following:-
DataTable dt = new DataTable("Try");
dt.Columns.Add("column1");
dt.Rows.Add("one");
dt.Rows.Add("two");
dt.Rows.Add("three");
and now set the datasource to dt.
Also you need to have atleast 1 row in datasource to get the grid displayed
Nana
|
|
|
|
|
Thank you,
I was doing it like this. Hope
private void Page_Load(object sender, System.EventArgs e)
{
if (! IsPostBack)
{
BindDataGrid();
}
}
private void BindDataGrid()
{
SqlCommand myCommand=new SqlCommand("SELECT * from Billing",con);
SqlDataAdapter myAdapter=new SqlDataAdapter(myCommand);
DataSet ds=new DataSet();
myAdapter.Fill(ds);
con.Open();
myCommand.ExecuteNonQuery();
dgbilling.DataSource=ds;
dgbilling.DataBind();
con.Close();
}
I had ever used this same code on another program and it worked properly.
could you help me from there please
Thanks.
|
|
|
|
|
use following code-
SqlDataAdapter myAdapter=new SqlDataAdapter("SELECT * from Billing", con);
con.Open();
DataSet ds=new DataSet();
myAdapter.Fill(ds);
con.Close();
dgbilling.DataSource=ds;
dgbilling.DataBind();
you dont need sqlcommand here at all.
And one suggestion - read more about what is an adapter, dataset etc why is it used n all.
I think one should know why is he/she using the object in the code.
Nana
|
|
|
|
|
Thanks for the advice. But the datagrid cannot appear,
|
|
|
|
|
is the qurey returning records?
Whats the count of rows in datasource?
Nana
|
|
|
|
|
In the datasource there is nonthing..
Thanks
|
|
|
|
|
when you use data adapters you do not need to open or close the connection, it does it by itselt. if the connection was already open before calling the fill command in data-adapert, it will leave it open and if it was close, it will open it get the data and then close it.
the Fill() function will get the data; so, you do not need to call the ExecuteNonQuery()
command again.
you might try the following:
private void BindDataGrid()
{
SqlCommand myCommand=new SqlCommand("SELECT * from Billing",con);
SqlDataAdapter myAdapter=new SqlDataAdapter(myCommand);
DataSet ds=new DataSet();
myAdapter.Fill(ds);
dgbilling.DataSource=ds;
dgbilling.DataBind();
}
this should give the required result.
|
|
|
|
|
GOD BLESS U
Dear Friends,
i am using a datagrid control in my ASP.NET application .
The datagrid has a checkbox column in it.Now apart from this the page also contains a button control named Delete.
what i need here is that when a user selects the checkbox in the datagrid,
and clicks the Delete button then that record should be deleted from both datagrid & database.
But if the user checks the SELECT ALL checkbox which is present in the datagrid header and clicks the delete button then all the records should be deleted from the datagrid & database.
pl give me the code for the above problem
This functionality is similar to any inbox page .
Pl kindly help me
Thanks a lot
Have a good day
Arun Hegde
-- modified at 4:28 Tuesday 20th February, 2007
|
|
|
|
|
i'm not sure whether u want to remove the records from the datagrid only or from the database as well.
in either case u can write the data-removing code in the event handler of the delete button.
in the event handler, get the datafrom the datagrid which will usually be of the Table datatype. so, now u can get the rows that have the checkbox checked and remove them from the table and bind the resulting table to the datagrid again.
i have used this mechanism to do something similar in my project as well, and it worked.
hope this helps.
|
|
|
|
|
I dont have VS.net installed right now so i can gove u hints.
You try the proper version.
For loop counter =1 to datagrid1.Rows.Count
if(((CheckBox)(datagrid1.Rows[counter].Controls[0].Controls[1])).Checked==true)
store it in some string say strToBeDeleted;
end loop
Now delete from db using strToBeDeleted ids.
and then again fire select query and bind the grid once again
what exactly we are doing is looping through all rows of grid.
use F10 to find exact position of the control in row as the Controls[0].Controls[1] code.
then we are casting it to checkbox and searching if its checked or not
Nana
|
|
|
|
|
Hello Friends ..This is Amit..and i want to use datagrid control in webpage..This control will display name and image ..Is it possible to display datagrid horizontally..detault view of datagrid is vertical...Tell me if u know..please...............
|
|
|
|
|
Hi
Can you please explain your need in detail.
Normally for displaying in Horizontal format,we use Datalist control.
|
|
|
|
|
hello...Actually I use 2 datalists say dtlist1 and dtlist2 and two pagers say pager1 and pager2 for each of them resp..and when the page is loaded dtlist2 is displayed by default. When user clicks on a button second dtlist2 is displayed...and after clicking on the pager for that datalist ..It shows first datalist i.e. dtlist1 ....becoz on page load dtlist2 is to displayed..To avoid such confict in pager..i decide to use datagrid which has its own pager..Then the problem occurs to show datagrid horizontally...Do u have any solution.....
|
|
|
|
|
Hi. I had this problem too
but I couldnt find any way ... I dont think it is possible ...
just you can work with datalist.
|
|
|
|
|
hi
Have 'Prev' and 'Next' LinkButtons outside the datalist.
Then Add like
<asp:datalist id="dl1" Runat="server" RepeatDirection="Horizontal" RepeatColumns="20" CellSpacing="7">
<ItemTemplate>
-------Add ur Template Column----
</ItemTemplate>
</asp:datalist>
Then bind the Datalist with the datasource.For Previous and Next Buttons, maintain the PageCount in a Viewstate and for Prev,decrement it by 1 and for Next,increment it by 1.
While binding the datasource,select the data from the db with respect to the ItemCount--from RepeatColumns,PageCount and TotalPageCount meaning that, the records which lies between the specified count given by ItemCount and pagecount,select the items from the db...
Try this
|
|
|
|
|
Hai to all,
Here i am getting a problem while using crystal report which were developed in MS-Access and the same reports i am using in asp.net using sqlserver as backend.
When i am connecting these crystal reports it is giveng error that not able to load.
My doubt is can we use crystalreports generated using Ms-Access in asp.net using SqlServer as backend.
If we can do how to do????What setting i have to give???
Bcz i have to use the already generated reports in my web application.
Can anyone give me a solution for this.
Thanks in advance
Regards,
Kissy
kissy
|
|
|
|
|
It should be common approach otherwise it does nt work.
If you did the report like the following one, Its very much possible to do that for all
http://www.codeproject.com/aspnet/crystal_report.asp[^]
Regards,
Sylvester G
Senior Software Engineer
Xoriant Solutions
sylvester_g_m@yahoo.com
|
|
|
|
|
Hi All,
I have a page which gives the following error on Firefox but works fine on IE. What can b the reason. please help
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
|
|
|
|
|
why you dont try to install IE Tab[^] Add-ons in firefox that integrate IE inside FireFox
I Love SQL
|
|
|
|
|
Is there any solution to make a control visible on scrolling and eliminate the change in location of the control. The control is to be placed directly on the form itself, should not use any container controls like panel
chandra
|
|
|
|
|
as far as i understand u're question you want to add a control to the form and make it visible while scrolling, right?
in such a case, just add the control to the form either in design time or at runtime.
set the autoscroll property of the form to true, and the visible property of the control to true (true by default).
if add during runtime, you need to specify the locatin where the control is to be placed and then you add the control to the container of the form e.g. this.Controls.Add(this.button1); in case of C# where 'button1' is the control u added.
|
|
|
|
|
tal reporthi frineds
i want to print barcode images on Crystal Report
barcode images are stored in database as varbinary datatype
i want fetch these images and show it on crystal report
how can i do this ?
thank you
|
|
|
|
|
Hello Everybody,
Can someone help in finding solution for dataview filter
I know how to use dataview filter and I had been using dataview for my application for biding 5 gridview.
Every gridview is binded by dataview. And when I'm using filter by sending filter criteria using textbox, it is possible to send any kind of string to filter the dataview.
Now problem is when I send
string like
1) *text, it works fine
2) text*, it works fine
3) te*xt, it fails why this is so?
Can someone please help me in this regard
Solution on this will be appreciated
Regards
Balasaheb Kahat
Balasaheb
Software Developer
Platform: Asp.net,vb.net
|
|
|
|
|
WILDCARD CHARACTERS
Both the * and % can be used interchangeably for wildcard characters in a LIKE comparison. If the string in a LIKE clause contains a * or %, those characters should be escaped in brackets ([]). If a bracket is in the clause, the bracket characters should be escaped in brackets (for example [[] or []]). A wildcard is allowed at the start and end of a pattern, or at the end of a pattern, or at the start of a pattern. For example:
"ItemName LIKE '*product*'"
"ItemName LIKE '*product'"
"ItemName LIKE 'product*'"
Wildcard characters are not allowed in the middle of a string. For example, 'te*xt' is not allowed.
for more info
=============
http://msdn2.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx[^]
Regards,
Sylvester G
Senior Software Engineer
Xoriant Solutions
sylvester_g_m@yahoo.com
|
|
|
|
|
ok then how to solve above problem using dataview because user can send string like te*xt, is there any way?
Please suggest some way to solve such problem
Regards,
Balasaheb
Software Developer
Platform: Asp.net,vb.net
Database: SQL Server 2000
|
|
|
|