|
Hi, I want to fill a datagrid from an ms access and i want to fill the datagrid in an ascending order. I want the last row of the database to be viewed in the first row of the datagrid. how can i do that? I have an autonumber as a primary key so that can give me some chance to make this happen. but how pls??
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
If you are using a datatable, you can sort those.
Dataview dv = new Dataview(DataTable);
dv.sort = "AutoId desc";
DataTable = dv.toTable();
datagrid.datasource = DataTable;
datagrid.databind();
|
|
|
|
|
i am not using any data table. How can you use the Order by Asc?
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
You have to use DataView to enable the sorting
just insert that table in dataview and call the sort property by giving the column name and ASC or DESC
example
dataView1.Sort = "Country DESC";
Happy Coding
Best Regards,
Haissam Abdul Malak
My Blog
|
|
|
|
|
I have a gridview which contains columns retreived from the database.i have in total 12 columns,in which 4 columns have checkbox's where ever there is a null in the database.i have done tht on the rowdatabound event of gridview dynamically by calling
CheckBox cb= new CheckBox();
i also have a checkbox in the first column of the gridview created using an itemTemplate tag of gridview,so tht when we check the corresponding row's checkbox,the values in tht row shall be updated
now my question is,i want to check the boxes in the column cells and update those corresponding row values in the database on button click.and also i need the checkbox state to be maintained.......how can i do this?any responses will be appreciated.
hi
|
|
|
|
|
To make this just a bit easier. Create a template column in your gridview. Hide the checkboxe in the itembound event when the database value is null. That solves the problem of maintaining the viewstate of the grid.
Now to loop through your gridview. Here is some sample code to put behind your button (or during any event really).
CheckBox cb;
foreach (GridViewRow r in this.GridView1.Rows)
{
cb = (CheckBox)r.FindControl("cbUpdate");
if (cb.Checked)
{
//put code to update database
}
}
|
|
|
|
|
Thanks for the reply.but it has not solved my problem completely.i have done similar to what u have replied,but in my case i need to loop through the inner cells of the gridview and as well the rows and check if there is a checkbox at any cell in the gridview,if exists,based upon my requirement i have to click the checkbox in those cells and also check the checkbox in the first column,and then update.what i want is to check the checkbox in the gridview cells and also the checkbox field created using the itemtemplate in the gridview.when i check the cells with checkboxes and then check the checkbox that is existing in the first column of the gridview and click the update button,then the data in the corresponding row should update.....
hi
|
|
|
|
|
srishree wrote: Thanks for the reply.but it has not solved my problem completely.i have done similar to what u have replied,but in my case i need to loop through the inner cells of the gridview and as well the rows and check if there is a checkbox at any cell in the gridview,if exists,based upon my requirement i have to click the checkbox in those cells and also check the checkbox in the first column,and then update.what i want is to check the checkbox in the gridview cells and also the checkbox field created using the itemtemplate in the gridview.when i check the cells with checkboxes and then check the checkbox that is existing in the first column of the gridview and click the update button,then the data in the corresponding row should update.....
Do you have a question?
|
|
|
|
|
yes,the question is in my previous mail,to simultaneously check the chekbox in the cells of cells[7],cells[8],cells[10],cells[11] and then click the checkbox in the itemtemplate to update it to the database.
how to do this?
hi
|
|
|
|
|
The Data Grid (at class level):
Protected WithEvents dgProducts As System.Web.UI.WebControls.DataGrid
Setting up the event handler (in a method called from Form_Load):
AddHandler dgProducts.ItemDataBound, AddressOf dgProducts_ItemDataBound
The event handler:
Private Sub dgProducts_ItemDataBound(ByVal sender As System.Object, ByVal e As DataGridItemEventArgs)
dgItemDataBound(sender, e, dgProducts, "ddl_4")
End Sub
The problem (VB.Net, ASP.Net v1.1):
A breakpoint set on the single line of this event handler is never hit even though this DataGrid does contain a DataBound column that does display data.
Eric
|
|
|
|
|
I think in VB.Net you need to put the handles keyword after the method.
<br />
Private Sub dgProducts_ItemDataBound(ByVal sender As System.Object, ByVal e As DataGridItemEventArgs) handles dgProducts.ItemDataBound<br />
|
|
|
|
|
Thanks... that did the trick!
Eric
|
|
|
|
|
Hello guys
Iam building a web application and i wonder if my pc was on a LAN can other computers on the same LAN open my application using a browser... like http://Ipaddress.... mypage.aspx
cuz i was trying to open my application from another computer on the lan, and i couldn't open it.
thanks in advance
Regards
Estarta
|
|
|
|
|
It should work just fine. It could be your machine has a firewall. Also, in IIS unchceck the allow anonymous access check box.
|
|
|
|
|
How can I stop my Dropdown from causing validation?
The dropdown has AutoPostBack = True. Every time I submit the form, the page is being validated from the top and therefore saving records fails
Any ideas?
Thank you.
|
|
|
|
|
Is the CausesValidation property of the dropdownlist set to False? It should default to false.
|
|
|
|
|
The <asp:DropDownList> doesn't have that property At least the one I have doesn't have it.
|
|
|
|
|
In asp.net 2.0 System.Web.Ui.WebControls.DropDownList does have the property. Which version are you using?
|
|
|
|
|
|
Strange, I just tried this in a 1.1 app that I have and the dropdownlist did not cause the validation. Just a guess but do you have a custom validator without the control to validate property set?
|
|
|
|
|
No I haven't. They all have the ControlToValidate property set. I'm still looking into it. It is very strange. Every time I try to submit the form, it restarts the page. Maybe this isn't due to the dropdown? I will investigate..
|
|
|
|
|
I'm trying to use the vid2swf component[^], but I get an error message when I try to call the ConvertFile method.
I have created a class Converter for the conversion, and I call the constructor with:
Converter converter = new Converter(Server.MapPath("Data/casablanca_finale.avi"), Server.MapPath("Data/casablanca_finale.flv"));
The constructor looks like this:
public Converter(string source, string destination) {<br />
_converter = new Project1.VideoConverter();<br />
_converter.ConvertFile(source, destination);<br />
}
When I call the constructor, I get the error "Error creating process : 2" at the line that calls ConvertFile.
I have checked that the paths sent to the constructor are correct. The source file exists. I have given full permission to the Data folder for the ASPNET account, so it shouldn't be any problem with file permissions.
I have googled the error message, which resulted in no hits at all.
Anyone got any idea what the source of the error is, or even what it means?
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
Guffa wrote: "Error creating process : 2"
Is that the full error message? Only reason I ask, is that whenever I've seen it before, it's been followed by "File not found", and has tended to be down to improperly referenced / GACed assemblies, or assemblies with "issues"
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
Yes, that is the full error message.
Don't you just love it when you get a descriptive error message that immediately pinpoints the source of the error?
---
It's amazing to see how much work some people will go through just to avoid a little bit of work.
|
|
|
|
|
how to use Ajax for Tab in Asp using Ajax 2.0
|
|
|
|