In my website I am dynamically binding the datasource to the grid based on the value in dropdownlist.
I want to edit and update the values in grid view and the respective updations should be done in the original database.
How can I do that?
In the most basic and direct way, you use the OnUpdateCommand event of the datagrid to invoke a server site handler. That handler will receive a DataGridCommandEventArgs parameter containing an Item property which is a grid row with updated values. Retrieve key and new values from that row and build a corresponding update command.
do you know how to bind dropdownlist vai datasourase?
and witch data sourse you use tell me first.
else you just make a SELECT query and fill the dataset after that you you must have to bind dropdownlist like this....
ds = dropdownlist.DataBind();
i think this help you.......
else you can tell me if any problem occure in this code..........
Related
I am having a problem with the RadGrid using Multiple Columns when I Bind a DataSource to the RadGrid. Firstly let me show some screenshots of what I am trying to do.
This is an example from Teleriks website under demos and the multiple columns (summary column) is what I am trying to achieve
This is the exception I am getting when I try and bind the control to a DataSource
This is the RadGrid I have set up in my ASP page.
Firstly I don't want to bind the datasource in my asp page. Secondly I wanted the "Product" and "Other" ColumnGroups to be used only as a Summary column and not to be bound to a datasource since these ColumnGroups are only used as headers for the other Columns.
Is there a workaround to not allow the ColumnGroups not to be bound to a DataSource while the normal columns are?
Firstly, each one of your columns is specifying a ColumnGroupName that does not exist. Your two groups are called OtherDetails and ProductDetails not Product and Other. Change them to resolve the exception.
Secondly, the GridColumGroups are simply groups, as they are not bound to any data from your datasource; they are simply for aesthetics.
I have a GridView which is completely user defined. The first column of the GridView is from the ListBox1. The headers are defined using ListBox2.
There fore I need to update rows of the GridView with some integer value and make sure the Gridview holds that value until a button is clicked.
Once the button is clicked I want to read each columns of the GridView that has values entered and create a table in the database with the headers names as columns and just replicate the GridView as table in database.
I have attached a screenshot of my GridView. Kindly help me fix this problem.
There are 2 key things to implement UPDATE logic in a GridView
In the GridView markup, you have to add an eventhandler for OnRowUpdating event
<asp:GridView ID="XXX" runat="Server" .....
OnRowUpdating="UpdateRecord" ..........>
Then you need to implement this "UpdateRecord" method referred above with your custom code which will basically retrieve the data from the grid row and update it to your datasource
You can refer to some sample code of how this can be achieved here
To point out again, in your case, since you want to dynamically create the table as well, you will need to additionally do that as well. Personally, i have no clue why you would go with such a design but in absence of any information, i assume you know best.
I have a grid view that, on selected index, will populate a details view. If the selected index happens to have multiple IP Address's I want to add additional fields to display them. They don't need to be databound since I know the data. I'm using the code below to create the additional template fields. This is done in the Data Binding event.
This works until I select a different row in the grid view, then no data is displayed in the details view. My theory is that it's trying to bind the data but there are a different amount of values returned from the database than controls to put them in. I guess is there an easier way to do this?
// Check for multiple IP
countIP = devicesDetails_CountIP(devicesDataKey);
if (countIP > 1)
{
TemplateField IPAddress2 = new TemplateField();
devicesDetailsView.Fields.Insert(0, IPAddress2);
}
Recently I came across this question, so here is a link that may be of help for future visitors
Create DetailsView from codebehind
hi i m having one datagrid...that have one check box field...whenever i check the check box that time that row will be inserted in database...but check box value is not set true value...it always return false value...i m using C# asp.net 2003 version..please help me...
If you data bind the grid in Page_Load, maybe you don't check for IsPostBack, so, your grid gets rebound and all previous changes like check are not persisted.
if(! Page.IsPostBack)
{
// Data bind the grid
}
Another possible reason is how you try to retrieve the checbox.
We really need to see some code in order to help you.
Its not immediately clear what your problem is. But if I had to guess, since ASP.NET 1.1. doesn't support two-way data binding, I would start with the code that reads the data from the form and updates your data source.
If we select the dropdown list Item then I want to display the Item Particulars in the Gridview Please Help me
On the SelectedIndexChanged of the dropdown rebind your GridView off of the selected value
Add a dropdownlist control, a button control, a grid view and an sqldatasource.
Configure the datasource first in sqldatasource.
I would recommend write a storeprodure to fetch data into the gridview (sqldatasource).
Bound the parameter to "controls" and select the dropdownlist. Now your DDL is bound to the gridivew. In his table click on advance properties and change property convertemptystringto null = false. (there property is something similar).
If you want a button to update the grid view, do this. Add the default event control to the button, put no code in it.
If you want to change the grid view content based on select directly then choose autopost on selected changed in properties of the DDL.
If everything is fine, this should populate your grid view based on contents in DropDownlist