DataGrid: Insert a new row value in footer based on the selected row value

Hi guys

        I need immediate help with the datagrid taht I am making. I have about 9 rows and with edit template item and a footer template for the new row that can be inserted in the db.

 

When someone hits the insert link in a row in the datagrid say its row 2 with OrgId = 10, I was the new row that comes as a footer row for the insert to populate orgId 10, leving the rest of the colums emtry for the user to fill in. But one column of this new row I want it to be populated with the value that was selected upon htting insert.

I hope I didnt confuse you, but I need help on it as soon as possible.

Here is my code.

 

Thanks

-Sarah

 

 

<asp:datagrid id="dgDisplayExperts" runat="server" OnItemCommand="DoItemCommand" width="100%"
     PageSize="5" AutoGenerateColumns="False" datakeyfield="eeid" AlternatingItemStyle-BackColor="#F0F0F0"
     AlternatingItemStyle-BorderStyle="Solid" AlternatingItemStyle-BorderColor="#ffffff" AlternatingItemStyle-Font-Size="10"
     BackColor="#CCCCCC" Font-Name="verdana" BorderColor="White" AlternatingItemStyle-Font-Name="verdana"
     Font-Size="10px" BorderWidth="1px" BorderStyle="Solid" Font-Names="verdana" OnPageIndexChanged="Grid_Change"
     AllowPaging="True" HorizontalAlign="Justify" ShowFooter="false">
     <AlternatingItemStyle Font-Size="10pt" Font-Names="verdana" BorderStyle="Solid" BorderColor="White" BackColor="#F0F0F0"></AlternatingItemStyle>
     <ItemStyle HorizontalAlign="Center"></ItemStyle>
     <HeaderStyle Font-Bold="True" HorizontalAlign="Center" Height="50px" Width="100px" CssClass="HeadingCellText"
      BackColor="#003366"></HeaderStyle>

 

 


     <Columns>
      <asp:TemplateColumn " HeaderText="Energy Expert Id">
       <HeaderStyle Width="2px"></HeaderStyle>
       <ItemTemplate>
        <asp:Label id=Label1 runat="server" text='<%# DataBinder.Eval(Container.DataItem,"eeid") %>'>
        </asp:Label>
       </ItemTemplate>
      </asp:TemplateColumn>
      <asp:TemplateColumn HeaderText="Organization Id">
       <ItemTemplate>
        <asp:Label text= '<%# populateOrganizationName(Convert.ToString(DataBinder.Eval(Container.DataItem,"OrgId")),Convert.ToString(DataBinder.Eval(Container.DataItem,"monitorType"))) %>' id="Label11" runat="server">
        </asp:Label>
       </ItemTemplate>

 

// Selected row value of should come in here
       <FooterTemplate>
        <asp:Label text= '<%# populateOrganizationName(SelectedValue,Convert.ToString(DataBinder.Eval(Container.DataItem,"monitorType"))) %>' id="Label4" runat="server">
        </asp:Label>
       </FooterTemplate>


       <EditItemTemplate>
        <asp:Label text= '<%# populateOrganizationName(Convert.ToString(DataBinder.Eval(Container.DataItem,"OrgId")),Convert.ToString(DataBinder.Eval(Container.DataItem,"monitorType"))) %>' id="Label8" runat="server">
        </asp:Label>
       </EditItemTemplate>
      </asp:TemplateColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" HeaderText="Edit" CancelText="Cancel"
       EditText="Edit">
      </asp:EditCommandColumn>
      <asp:TemplateColumn HeaderText="Delete">
       
       <ItemTemplate>
        <asp:LinkButton CommandName="Delete" Text="Delete" ID="btnDel" Runat="server" /></asp:LinkButton>
       </ItemTemplate>
       
       <FooterTemplate>
        <asp:LinkButton CommandName="Insert" Text="Add" ID="btnAdd" Runat="server" /></asp:LinkButton>
       </FooterTemplate>
      </asp:TemplateColumn>
      <asp:TemplateColumn HeaderText="Insert New Expert">
       
      <ItemTemplate>
        <asp:LinkButton Width = "75px" CommandName="InsertNewExpert" Text="NewExpert" ID="Linkbutton1" Runat="server" /></asp:LinkButton>
       </ItemTemplate>
       </asp:TemplateColumn>
      
     </Columns>
    </asp:datagrid> 

 


Sarah Cameron Benjamin
0
SarahBenjamin
2/15/2007 6:44:56 PM
asp.net.vs2002-vs2003 3502 articles. 0 followers. Follow

0 Replies
257 Views

Similar Articles

[PageSpeed] 36

Reply:

Similar Artilces:

select the row of the datagrid whose value is same as one of the value of row of datagrid
hellow all,  I have a datagrid which is bound to the ordertable,so all the orderdetails are shown on the page load. but my requirement is that,i have a textbox and a search button,when the user enter the order number in the text box and click on the search button the datagrid should show that record whose order number is entered by the user n most imp that the record may be in the 65th or 34th row of the datagrid,i wants to put it in the first row. how to do it. If there's a reason you can't filter down to just the one row, you'll have to come up with some paging algorithm that wil...

How to insert new row between the existing row in the gridview dynamically and how to insert value in it
hi,       I have a grid view i populate the grid with student records, i have a button called sub_Average when i click the button, the rows should reorder(groped) depend on department, and the average of each department should come under the end of each department (ie) a new row should be inserted for display Average of each department. Each new row should insert below the end of each department. Now my problem is i populate the records directly from dataset, so i dn't know how to insert a new row for average in the grid dynamically for each depar...

New row in datagrid: Old values are overwritten instead of a new row appears
First post from a not so experienced VS.NET/VB programmer I am writing a short piece of code that allows users of the program to enter some data in textboxes and then by clicking on a button, allow them to add the information they put in the textboxes to a datagrid. The first time they press this button, it shows perfectly in the datagrid on the form, but the 2nd time it only updates the first row instead of adding a new row.By doing some searches on Google, I found out that I am not using the right code, but I can't find how to do it correctly. I hope to get an answer here.Below you see...

Select some values from a row and Insert on another row
I have a table wih multiple records and some has common values. For example, new child row need to inherit some of parent's data. Here is how I want to do: Select [parent data1], [parent data2] from [TABEL] where id = parent Insert INTO [TABLE]  ([child id], [child data1], [child data2] ) VALUES [child  id] [parent id] [parent id]........... I was thinking about using Selected and Inserting events but not sure how. Please help?  Thanks, try Insert INTO [TABLE]  ([child id], [child data1], [child data2] ) Select @tiChildID ,[parent d...

how do i go/setfocus to a datagrid row, based on an outside selection e.g. selected value from dropdownlist
I can retirieve the string value out of the selectedvalue from a dropdownList using that value -> how do I set focus to the row in a datagrid with the same unique value and update the datagrid??. private void ddlBook_SelectedIndexChanged(object sender, System.EventArgs e) { fails, cant convert string to int ---> dataGrig.SelectedIndex = ddlBook.SelectedValue; dataGrid.PreRender(); // trying to refresh here to new focused row } Hi, you need to identify the row in the datagrid that has the value you've selected in the dropdownlist and ...

Referencing BoundField Datafield values of Datagrid row when button on same row is selected????
Given the Gridview below: When I select the button "Rate" and fall into this code: How can I reference "carriercode" and other . Apparently selecting the button does not select the row. I've tried find control, and everything returns that I must reference and instance of the object.  CommandArgument is being sent corrently. If the button were a buttonfield I would have no problem getting the row index, but Im having problems because the button is an asp.net runat server button. snip...  Protected Sub PendingGridView_RowCommand(ByVal sender As Object, By...

Select particular row and take the value of particular column selelcted row and pass the value to another page
Hi,  i'm making one webform where i'm displaying datafileds  through GridView. GridView has 6 columns like name, Id, & etc with two icons. one is email icon and another one is mobile icon. In those there are three Buttons(name, email, mobile). When the user clicks on email then it takes the values of email and it forwards to another page and mobile too. Here i can set and pass the  value of email, i'm able to pass the values when i click on email icon and it is passing successfully to another page but it is playing the same action whe...

How to select/setfocus datagrid row based on datakey value!
Hi everyone, I have Datagrid which binds(EmpID,EmpName) data from a table in a webform(.aspx) using VB.NET. I have FIND button which opens popup window. The popup window has DropDownList control(EmpID,EmpName) where user can select a EmpName. (The reason why i use popup, because Datagrid has long list). Then i pass Dropdown selectedvalue to parent window and close popup. Now i problem is, How to select a Datagrid row based on DataKey value? I have to highlight row which user selected from Dropdown. I need something like this, Datagrid.selectedIndex = {datakeyvalue index} I'm look...

Get column values of selected row in datagrid on a new page...
I have a datagrid, but its column has columns from multiple tables...(i.e. it has UNION in the sql statements and some columns are created by concatenating multiple columns together)One of the column has a hyperlink.  When the hyperlink of a particular row is clicked, a new form is loaded.  Is it possible to populate the fields on this new form with the column values of the selected row - i.e. without doing another SQL lookup? (i.e. basically reading all the column values of the selected row and then displaying it on a new form) Hi,You look like back to the question of passi...

Datagrid Selecting a Row and Inserting in New Datagrid
Hi, I am using a two datagrid. In first Datagrid I have Select and it will select a row. My question is 1. How do I insert the selected row in the second datagrid. may be on the same webpage or different webpage. Waiting for the reply ASAP. Thanks, Paramdeep...

How to add values to DataGrid row by row
How do I add values to a DataGrid row by row without using a DataSource? Is this possible? Or should I just use a table? my code works like this: BoundColumn Col1 Add Col1 to DataGrid1 for every str in stringarray { Add New Row DataGrid1 with Col1 = str } Thanks. may be following URLwill help you http://www.123aspx.com/ReadReviews.aspx?res=359 Arvind Well, DataGrid was found not to make you do it the old way as in ASP 3.0. You can still get a datasource like datatable and then loop in it and display all the data row by row, is this what you want ? ...

How concate n rows value into single row value
Daer Sir, I have list(5 rows) of name in a datawindow I want to concate all rows into sinle row regards Indus ---== Posted via the PFCGuide Web Newsreader ==--- http://www.pfcguide.com/_newsgroups/group_list.asp Are you trying to display it in one row in the same DW which retrieves the five separate rows ? Do you need those five rows for any processing other than concatenating them ? What functionality are you trying to provide ? Understanding that may help us provide other options. There are several approaches you could take, primarily revolving around reading each va...

Iwant to select a row and column in gridview with select radiobutton. but No checked change event.below put a button .if click that button to seleced row values will select
I want to select a row and column in gridview using radiobutton in gridview . if which radio button is select that row will select and i want that row column values in outside individual textboxes of next page.  but in that only single radiobutton will select and no post back="true" bcz iam not using checked change property. i inserted button below gridview. if i click the that selected row and columns values are stored into textboxes of next page im using this code .but im getting one column in that row. but i want all columns in that selected row so plz repla...

How to select a field value from a selected row from a DataGrid in order to use it as a parameter
I am working on a web application, and I have two DataGrids.  Then end-User is supposed to select a row from one of the grids, and the event should select a key from that row in order to use it as a parameter to fill the other DataGrid.  I have been trying to do so, but I dont work the same way as I used to do it in windows applications.   I would appreciate any suggestions,   Thanks. Is there some code we can look at? I've done similar things and I've never had any problem with them. In the first grid have a select column, when it is clicked you can catch the Sel...

Web resources about - DataGrid: Insert a new row value in footer based on the selected row value - asp.net.vs2002-vs2003

Resources last updated: 12/18/2015 1:46:55 PM