I am still not able to figure the problem out Can you please look at the code and advice, thanks.......
aspx for datagrid....
<div style="BORDER-RIGHT: #00006f thin solid; BORDER-TOP: #00006f thin solid; BACKGROUND-IMAGE: none; BORDER-LEFT: #00006f thin solid; WIDTH: 99.2%; BORDER-BOTTOM: #00006f thin solid; HEIGHT: 200px; BACKGROUND-COLOR: #d2d2d2"
align="center"><asp:datagrid id="dgReceivingInfo" runat="server" Width="888px" EnableViewState="True" BorderStyle="Solid"
BorderColor="Black" AutoGenerateColumns="False" HorizontalAlign="Justify" PageSize="15" BorderWidth="1" cssclass="tblMain"
headerCSS="tblHeader" bodyCSS="tblBody" bodyHeight="190">
<SelectedItemStyle BackColor="Cornsilk" />
<Columns>
<asp:TemplateColumn HeaderText="Add Comment" HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="74px"
ItemStyle-Width="74px" ItemStyle-HorizontalAlign="Center" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1"
ItemStyle-BorderStyle="Solid" ItemStyle-BorderWidth="1">
<HeaderStyle></HeaderStyle>
<ItemStyle Height="20px"></ItemStyle>
<ItemTemplate>
<Center>
<asp:button id="btnEdit" Text="Edit" runat="server" Font-Size="0.7em" Height="18px" width="60px"
EnableViewState="True" Enabled="true" CommandName="Edit" />
</Center>
</ItemTemplate>
<EditItemTemplate>
<asp:button id="btnSave" Text="Save" runat="server" Font-Size="0.7em" Height="18px" width="33px"
EnableViewState="True" Enabled="true" CommandName="Save" />
<asp:button id="btnCancelChanges" Text="Cancel" runat="server" Font-Size="0.7em" Height="18px"
width="35px" EnableViewState="True" Enabled="true" CommandName="Cancel" />
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="False">
<Itemtemplate>
<asp:Label Runat = "server" ID = "lblReceiptID" Text='<%# DataBinder.Eval(Container.DataItem, "ReceiptID")%>'>
</asp:Label>
</Itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn Visible="False">
<Itemtemplate>
<asp:Label Runat = "server" ID = "lblPOID" Text='<%# DataBinder.Eval(Container.DataItem, "POID")%>'>
</asp:Label>
</Itemtemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="PO Line #" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1"
ItemStyle-BorderStyle="Solid" ItemStyle-HorizontalAlign="Left" ItemStyle-BorderWidth="1">
<HeaderStyle HorizontalAlign="Center" BackColor="LightGray" Width="75px"></HeaderStyle>
<ItemStyle Height="20px" Width="75px"></ItemStyle>
<ItemTemplate>
<asp:Label Runat = "server" ID = "lblPOLineNo" Height = "20px" Width = "72px" text='<%# DataBinder.Eval(Container.DataItem,"LineNumber") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="PO Item #" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1"
ItemStyle-BorderStyle="Solid" ItemStyle-HorizontalAlign="Left" ItemStyle-BorderWidth="1">
<HeaderStyle HorizontalAlign="Center" BackColor="LightGray" Width="70px"></HeaderStyle>
<ItemStyle Width="70px"></ItemStyle>
<ItemTemplate>
<asp:label Runat = "server" ID="lblItemID" Height="20px" Width = "67px" text='<%# DataBinder.Eval(Container.DataItem,"ItemID") %>'>
</asp:label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Item Description" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1"
ItemStyle-BorderStyle="Solid" ItemStyle-HorizontalAlign="Left" ItemStyle-BorderWidth="1">
<HeaderStyle HorizontalAlign="Center" BackColor="LightGray" Width="350px"></HeaderStyle>
<ItemStyle Width="350px"></ItemStyle>
<ItemTemplate>
<asp:label Runat = "server" ID="lblItemDesc" Height="20px" Width = "347px" text='<%# DataBinder.Eval(Container.DataItem,"Description") %>'>
</asp:label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Quantity Received" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1"
ItemStyle-BorderStyle="Solid" ItemStyle-HorizontalAlign="Right" ItemStyle-BorderWidth="1">
<HeaderStyle HorizontalAlign="Center" BackColor="LightGray" Width="70px"></HeaderStyle>
<ItemStyle Width="70px"></ItemStyle>
<ItemTemplate>
<asp:Label Runat = "server" ID="lblQtyReceived" Height="20px" Width="67px" text='<%# DataBinder.Eval(Container.DataItem,"Quantity") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Receiving Comments" HeaderStyle-BorderStyle="Solid" HeaderStyle-BorderWidth="1"
HeaderStyle-HorizontalAlign="Center" ItemStyle-BorderStyle="Solid" ItemStyle-HorizontalAlign="Left"
ItemStyle-BorderWidth="1">
<HeaderStyle BackColor="LightGray" Width="230px"></HeaderStyle>
<ItemStyle Height="20px" Width="230px"></ItemStyle>
<ItemTemplate>
<asp:label Enabled="True" Font-Size="8" ID="lblRecvComments_values" Text='<%# DataBinder.Eval(Container.DataItem,"ReceivingComme nts") %>' Width="230px" Runat="server" Height="20px">
</asp:label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList Enabled="True" Font-Size="8" ID="ddRecvComments" Width="230px" Runat="server" Height="20px" DataSource="<%# TempDataView %>"
OnSelectedIndexChanged = "ddRecvComments_SelectedIndexChanged" DataValueField="ReceivingComments" DataTextField="ReceivingComments" AutoPostBack="True">
</asp:DropDownList>
<asp:TextBox ID ="txtRecvComments" Text='<%# DataBinder.Eval(Container.DataItem,"ReceivingComme nts") %>' Width="230px" Runat="server" Height="20px"></asp:TextBox>
</EditItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></div>
VB.NET
DataBinding and loading the dropdown in PageLoad, This code is inside the Not(Page.isPostBack) condition
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not (Page.IsPostBack) Then
LoadDropDownList()
Dim ds_ReceivingInfo As DataSet = DataBind_ReceivingInfo("spReceivingInfo2")
dgReceivingInfo.DataSource = ds_ReceivingInfo
dgReceivingInfo.DataBind()
Session.Add("ds_ReceivingInfo", ds_ReceivingInfo)
End If
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
UpdateReceivingInfo()
End Sub
Protected Sub ddRecvComments_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddRecvComments.SelectedIndexChanged
Dim ddRecvComments2 As DropDownList = CType(sender, DropDownList)
If ddRecvComments2.SelectedValue = "Other" Then
'ddRecvComments2.SelectedValue = ""
ddRecvComments2.Visible = False
Else
ddRecvComments2.Visible = True
ddRecvComments2.AutoPostBack = False
End If
End Sub
Public Function DataBind_IssuedPODetails(ByVal SPName As String, Optional ByVal TableName As String = Nothing) As DataSet
Dim param1 As String
Dim ds As DataSet = New DataSet
Dim da As SqlDataAdapter
Dim conn As SqlConnection = clsConnection.GetConnection()
param1 = Session.Item("arrVal_Ix")
Dim Cmd As SqlCommand = New SqlCommand(SPName, conn)
Cmd.CommandType = CommandType.StoredProcedure
Cmd.Parameters.Add("@POID", param1)
da = New SqlDataAdapter(Cmd)
conn.Open()
If (TableName = Nothing) Then
da.Fill(ds)
Else
da.Fill(ds, TableName)
End If
conn.Close()
Return (ds)
End Function
Public Sub LoadDropDownList()
'Dim TempDataView1 As DataView
Dim drv As DataRowView
Dim ds_DropDownList = New DataSet
Dim da As SqlDataAdapter
Dim conn As SqlConnection = clsConnection.GetConnection()
Dim cmd As SqlCommand = New SqlCommand("Select * from t_ReceivingComments", conn)
da = New SqlDataAdapter(cmd)
da.Fill(ds_DropDownList, "t_ReceivingComments")
'Dim y As Int32 = ds_DropDownList.Tables("t_ReceivingComments").Rows .Count
TempDataView = New DataView(ds_DropDownList.Tables("t_ReceivingCommen ts"))
drv = TempDataView.AddNew
drv("ReceivingComments") = "Other"
End Sub
Public Function UpdateReceivingInfo()
Try
Dim conn As SqlConnection = clsConnection.GetConnection()
Dim da As SqlDataAdapter
da = New SqlDataAdapter("spPOReceivingInfoSelect", conn)
da.SelectCommand.CommandType = CommandType.StoredProcedure
With da.SelectCommand.Parameters
.Add(New System.Data.SqlClient.SqlParameter("@ReceiptID", System.Data.SqlDbType.VarChar, 10, "ReceiptID"))
.Add(New System.Data.SqlClient.SqlParameter("@POID", System.Data.SqlDbType.BigInt, 8, "POID"))
.Add(New System.Data.SqlClient.SqlParameter("@ItemID", System.Data.SqlDbType.VarChar, 25, "ItemID"))
.Add(New System.Data.SqlClient.SqlParameter("@wh_id", System.Data.SqlDbType.VarChar, 10, "wh_id"))
End With
da.UpdateCommand = New SqlCommand(Nothing, conn)
With da.UpdateCommand
.CommandText = "UPDATE t_POReconciliation1 SET ReceivingComments = @ReceivingComments WHERE (ReceiptID = @ReceiptID) AND (POID = @POID) AND (wh_id = @wh_id) AND (ItemID = @ItemID); "
.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ReceiptID", System.Data.SqlDbType.VarChar, 10, "ReceiptID"))
.Parameters.Add(New System.Data.SqlClient.SqlParameter("@POID", System.Data.SqlDbType.BigInt, 8, "POID"))
.Parameters.Add(New System.Data.SqlClient.SqlParameter("@wh_id", System.Data.SqlDbType.VarChar, 10, "wh_id"))
.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ItemID", System.Data.SqlDbType.VarChar, 25, "ItemID"))
.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ReceivingComm ents", System.Data.SqlDbType.VarChar, 256, "ReceivingComments"))
End With
Dim ds As DataSet = Session("ds_ReceivingInfo")
Dim x As Int32 = ds.Tables(0).Rows.Count()
Dim yu As Int32 = ds.Tables(0).Rows.Count()
da.Update(ds)
ds.AcceptChanges()
Return True
Catch ex As Exception
Return False
End Try
End Function
Thanks for your time...... :)