Write an Article Write a Tutorial Add a Fast Code* *Fast Code might be any helpful code with brief comment
Stem Cells Blood Banks Insurances .Net Hosting Credit Cards PC Rental Business
Tutorials: ASP .NET C# .NET VB .NET Articles: ASP .NET C# .NET VB .NET Fast Code: ASP .NET C# .NET VB .NET
Let us see how does our Gridview in .aspx Page look like.
Our .aspx Page;
OnRowUpdating="GridView1_RowUpdating" > DataSourceID="SqlDataSource1" DataValueField=username AutoPostBack="True" SelectedValue='<%# Bind("username")%>'> Select an Item
Our Dropdownlist is embeded in the "ItemTemplete" of the Gridview. One more thing before going next, Always use Bind() with the Controles in both ItemTemplate and EditItemTemplate. For this Demo we are using SqlDataSource Object as DataSource. Now let us see how does "SqlDataSource" looke like.
SelectCommand="SELECT * FROM [ChatMessages]" UpdateCommand="UPDATE [ChatMessages] SET [username] = @username, [message] = @message WHERE id=@id">
You noticed that in the Gridview Code we defined an event called "RowUpdating" In the code behind we will show the event code. Now, let us see how does the code behind look like.
Code behind for the Row Update event;
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) { string struName = ((DropDownList)((GridView)sender).Rows[e.RowIndex].FindControl("DropDownList1")).SelectedValue; e.NewValues["username"] = struName; e.Cancel = false; }
I understand the code yes but simply do not understand your intetion. Did you honestly explain any thing to the newbies
30/12/2006 03:27:47 UTC
Hi kip,
Please, help us improving.
30/12/2006 16:39:52 UTC
02/02/2007 23:35:05 UTC
Omerkamal,
I had a GridView and there is a dropdownlist in the GridView. Here is my problem when i was clicking on the EDIT button it is displaying an error.
Parameter name: value 'ddlConfiguration' has a SelectedValue which is invalid because it does not exist in the list of items. Can u plz help me in this?
11/07/2007 15:38:08 UTC
That means that the value which is suppoed to be selcted does not exsit in the ConfigNameDS Database or you are accessing different Fields of the Database.
The Values must lie in both the databases. The Database you attaching to the Gridview and the one you attaching to the DropDownList. Moreover, your Configuration Field must represent the same field which you bouding to the DropDownList.
12/07/2007 03:09:58 UTC
am doing one project in that create 2 textboxs enter one textbox a number then show the 2nd textbox result multiplication of that number with 7
20/09/2007 00:40:44 UTC
Hi,
18/10/2007 03:16:05 UTC
how i can display dropdownlist after clicked in edit button \\ i want call this finction to display DDL
<%
<
Private
myConnection =
myCommand =
myConnection.Open()
myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
DropDownList1.DataSource = myDataReader
DropDownList1.DataValueField =
DropDownList1.DataTextField =
DropDownList1.DataBind()
myDataReader.Close()
myConnection.Close()
15/11/2007 05:47:12 UTC
15/01/2008 04:44:34 UTC
i want to add combo box in gride and when i select one value in that como it display on gride
and attrective disigen tool in dot net
26/03/2008 11:38:24 UTC
29/05/2008 14:26:54 UTC
hw can i bind a grid row to a textbox in another form i.e when the link in the grid is clicked the corresponding record in the row is displayed in the textbox in another form
24/07/2008 04:26:10 UTC
18/09/2008 18:54:06 UTC
02/10/2008 00:45:09 UTC
05/12/2008 14:04:11 UTC