473,396 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

cannot save the dropdownlist data to datagrid. iam new to .net, help me out please iam struck up here

(Type your message here)

--------------------------------
From: vinod babu

Here my adding a new row code

Private Sub cmdadd1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdadd1.Click
If DataExists() = False Then Exit Sub
MaintenancereportDataSet = DataRetrieve()
Dim rowNew As System.Data.DataRow = MaintenancereportDataSet.Tables(0).NewRow
pre = Mid(txtreportno.Text, 1, 2)
result = pre + "1"
checkId1(result)
Session("type2") = UCase(resultFinal)
rowNew.Item("SLNO") = type2
rowNew.Item("MDENGR") = type2
MaintenancereportDataSet.Tables(0).Rows.Add(rowNew )
MaintenanceGrid.EditItemIndex = MaintenanceGrid.Items.Count
MaintenanceGrid.DataSource = MaintenancereportDataSet
MaintenanceGrid.DataBind()
DataSave(MaintenancereportDataSet)
empnam()
End Sub
where every thing fine working out it got edited row with the dropdownlist with the data, but i have a problem of saving
this is my procedure to save the data. here i need a procedure to get the datatextfield value and store it to database.

Private Sub cmdUpdate1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate1.Click
Try
If DataExists() = False Then Exit Sub
If MaintenanceGrid.EditItemIndex = -1 Then Exit Sub
Dim intCount As Integer
Dim MaintenancereportDataSet As DataSet = DataRetrieve()
With MaintenanceGrid
For intCount = 1 To .Items(.EditItemIndex).Cells.Count
If intCount = .Items(.EditItemIndex).Cells.Count _
Then Exit For
' Check that a control exists in this position
If .Items(.EditItemIndex).Cells(intCount).Controls. _
Count Then
' Check for a standard TextBox
If TypeOf (.Items(.EditItemIndex).Cells(intCount). _
Controls(0)) _
Is TextBox Then
Dim strValue As String = CType(.Items(. _
EditItemIndex). _
Cells(intCount).Controls(0), TextBox).Text
If strValue <> "" Then
' This isn't null, so store value
MaintenancereportDataSet.Tables(0).Rows(.EditItemI ndex).Item( _
intCount - 1) = strValue
If intCount = 9 Then
Session("extracharge") = UCase(strValue)
End If
ElseIf intCount = 1 Then
MaintenancereportDataSet.Tables(0).Rows(.EditItemI ndex).Item( _
intCount - 1) = Session("type2")
ElseIf intCount = 2 Then
MaintenancereportDataSet.Tables(0).Rows(.EditItemI ndex).Item( _
intCount - 1) = txtreportno.Text
ElseIf intCount = 3 Then
MaintenancereportDataSet.Tables(0).Rows(.EditItemI ndex).Item( _
intCount - 1) = txtcusid.Text
Else
' Treat empty value as null
MaintenancereportDataSet.Tables(0).Rows(.EditItemI ndex).Item( _
intCount - 1) = System.DBNull.Value
End If
End If
End If
Next
.SelectedIndex = -1
.EditItemIndex = -1
DataSave(MaintenancereportDataSet)
.DataSource = MaintenancereportDataSet
.DataBind()
End With
Catch
lblmsg.Text = Err.Description
End Try
End Sub

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>D/4Z22zpwUO67odNEHBmyQ==</Id>
Nov 18 '05 #1
0 1258

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
2
by: Dominic | last post by:
Hi guys, I'm not sure if this question belongs to FAQ, but I couldn't find a concrete answer. I created a Datagrid control using ItemTemplate, but it's NOT a in-place editing datagrid. One of...
5
by: DC Gringo | last post by:
I've got a command button to submit a value from a dropdown list that should then filter a SELECT query. I'm simply appending a WHERE colx = <variableSelectedFromDropdownList>. How do I pass this...
1
by: m3ckon | last post by:
Hi there, please help if you can, I'm having an issue with droponnlists in a datagrid I have a datagrid which is populated from a query .. all works fine I've added two extra columns, one...
6
by: VB Programmer | last post by:
I have an itemtemplate in a datagrid. I'm trying to set it's value based on data. Having no trouble with the textbox. But, how do I do the same thing for a dropdownlist???? <ItemTemplate>...
3
by: Tim::.. | last post by:
Hi... Can someone please tell me what I'm doing wrong here... I have a dropdownmenu populated from a database! The idea is that a user selects an option from the dropdownlist which then loads...
4
by: Mark Waser | last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a datagrid. In the page PreRender step, the selected index of the datagrid is successfully set during databinding. Yet,...
0
by: bh | last post by:
I'm trying to edit data in a datagrid through a dropdown list with different id/text values. The problem comes in when I click the edit button & nothing appears to be happening. Did I do...
1
by: simonyong | last post by:
hello, everyone im a newbie to asp.net, getting nut with just a simple stuff please give me some direction How to use dropdownlist when user select one of the method in dropdownlist The fields...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.