[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 237
  • Last Modified:

e.Item.Cells.Text is not picking up value from ASP .net 1.1 datagrid

I was able to pick up values from my datagrid before using e.Item.Cells[subscript].Text, but now all I'm picking up is a blank value.  Here's my grid definition:

<ASP:DATAGRID id="dgComplianceNotes" runat="server" autogeneratecolumns="False" CellPadding="5"
                                                                                                oneditcommand="Edit_dgComplianceNotes" OnPreRender="dgComplianceNotes_PreRender" cssClass="datagrid"
                                                                                                GridLines="Vertical" Height="120px">
                                                                                                <HeaderStyle ForeColor="White" CssClass="dgHeader" runat="server"></HeaderStyle>
                                                                                                <Columns>
                                                                                                      <asp:BoundColumn DataField="Owner" HeaderText="User"></asp:BoundColumn>
                                                                                                      <asp:BoundColumn DataField="RevisedDate" HeaderText="Date/Time"></asp:BoundColumn>
                                                                                                      <asp:BoundColumn DataField="RecordedNotes" HeaderText="Note"></asp:BoundColumn>
                                                                                                      <asp:BoundColumn Visible="False" DataField="Project_Note_Type_Id"></asp:BoundColumn>
                                                                                                      <asp:BoundColumn Visible="False" DataField="Participant_ID"></asp:BoundColumn>
                                                                                                      <asp:BoundColumn Visible="False" DataField="FormattedRevisedDate"></asp:BoundColumn>
                                                                                                      <asp:EditCommandColumn EditText="Edit" HeaderText="Edit"></asp:EditCommandColumn>
                                                                                                </Columns>
                                                                                          </ASP:DATAGRID>


Here's my code:

protected void Edit_dgComplianceNotes(object sender, DataGridCommandEventArgs e)
            {            
                  try
                  {

                        if (Session["participant_id"].ToString() == e.Item.Cells[4].Text)
                        {
                        StringBuilder s = new StringBuilder("<script language='javascript'> window.open('EditNotes.aspx?ProjectNoteTypeID=");
                        s.Append(e.Item.Cells[3].Text.TrimEnd());
                        s.Append("&Participant_ID=" + e.Item.Cells[4].Text.TrimEnd());
                        //StringBuilder t = new StringBuilder("&RevisedDate=" + (e.Item.Cells[6].Text.TrimEnd()));
                        StringBuilder t = new StringBuilder("&RevisedDate=" + (e.Item.Cells[5].Text.TrimEnd()));
                        t.Replace(' ', '+');
                        s.Append(t);
                        //s.Append("&Notes=" + e.Item.Cells[5].Text.TrimEnd());
                        s.Append("', '', 'height=300, width=400, scrollbars=no'); </script>");
                        string strScript = s.ToString();
                        
                        string strScript2 = "<script language=JavaScript>alert(" + s.ToString() + ");";

                        if (!Page.IsStartupScriptRegistered("clientScript"))
                              Page.RegisterStartupScript("clientScript", strScript);

                        }
                        else
                        {
                              dgComplianceNotes.DataSource = dgComplianceNotes_Data();
                              dgComplianceNotes.DataBind();
                              //tblComplianceNotes.Visible = true;
                        }

                  }
                  catch(Exception Ex){throw Ex;}
            }

I'm using framework 1.1.
0
Kaporch
Asked:
Kaporch
  • 2
1 Solution
 
Ajay SharmaCommented:
u can not access a columsn value which is not visible

First u have to make that column visible true

If u do not want to show the column then set its width to 0px
0
 
KaporchAuthor Commented:
I tried changing the grid to:

<td><ASP:DATAGRID id="dgComplianceNotes" runat="server" autogeneratecolumns="False" CellPadding="5"
                                                                                                oneditcommand="Edit_dgComplianceNotes" OnPreRender="dgComplianceNotes_PreRender" cssClass="datagrid"
                                                                                                GridLines="Vertical" Height="120px">
                                                                                                <HeaderStyle ForeColor="White" CssClass="dgHeader" runat="server"></HeaderStyle>
                                                                                                <Columns>
                                                                                                      <asp:BoundColumn DataField="Owner" HeaderText="User"></asp:BoundColumn>
                                                                                                      <asp:BoundColumn DataField="RevisedDate" HeaderText="Date/Time"></asp:BoundColumn>
                                                                                                      <asp:BoundColumn DataField="RecordedNotes" HeaderText="Note"></asp:BoundColumn>
                                                                                                      <asp:BoundColumn DataField="Project_Note_Type_Id" ItemStyle-Width="0px"></asp:BoundColumn>
                                                                                                      <asp:BoundColumn DataField="Participant_ID" ItemStyle-Width="0px"></asp:BoundColumn>
                                                                                                      <asp:BoundColumn DataField="FormattedRevisedDate" ItemStyle-Width="0px"></asp:BoundColumn>
                                                                                                      <asp:EditCommandColumn EditText="Edit" HeaderText="Edit"></asp:EditCommandColumn>
                                                                                                </Columns>
                                                                                          </ASP:DATAGRID></td>

I can still see the columns, and I still can't pick up the values from the cells (coming in as blanks).
0
 
Ajay SharmaCommented:
hey just tell me one thing.
R u trying to update data in the datagrid ??
if yes then ==>

Do not put ur code in the  "Edit_dgComplianceNotes"
in the  "Edit_dgComplianceNotes"   write  

dgComplianceNotes".EditItemIndex = e.Item.ItemIndex
fxFillGatagrid

======================================================================

In the
Update_dgComplianceNotes put ::

        Dim txtEdit As TextBox = e.Item.Cells(4).Controls(0)
        Dim rwid As String
        rwid = e.Item.Cells(0).Text
        Call FXupdate(txtEdit.Text), rwid)   '''(this is code th call the function which accepts values and updates values into DB)

        dgComplianceNotes .EditItemIndex = -1
        fdaatgridFillingcode()
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now