Binding GridView Columns with controls outside the GridView

Hi

I already posted this issue but couldn't get the proper resolution so making it more clear;

Problem is my controls are outside the grid. Like ive text boxes, for First Name and Last Name and dropdown for country. User can fill these fields for entering a new record and also update the existing by selecting it from the grid.

Like user selects a row from the grid and its contents will be displayed on the textboxes and drop downs that are out side the grid.

Hope i could explain it better now.

 


Regards
Mohsin Shahzad
0
wolfenstein4u
12/28/2007 8:55:37 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

5 Replies
2602 Views

Similar Articles

[PageSpeed] 4

You could use a DetailsView or FormView control that is linked to the GridView.  This way, you are still updating external from the GridView, but using another *View control that will also link to a DataSource that allows for updating and inserting of records on a one-by-one basis.

For more information, look at the QuickStart tutorials for the DetailsView and FormView controls.
 


Christopher Reed
"The oxen are slow, but the earth is patient."
0
Careed
12/28/2007 12:49:06 PM

wolfenstein4u:

I already posted this issue but couldn't get the proper resolution so making it more clear;

Problem is my controls are outside the grid. Like ive text boxes, for First Name and Last Name and dropdown for country. User can fill these fields for entering a new record and also update the existing by selecting it from the grid.

Like user selects a row from the grid and its contents will be displayed on the textboxes and drop downs that are out side the grid.

 

where is your problem?

Do you have confusion to insert and update datas?

Do you have any button in gridview to update record?
If yes, on Row_Command event of gridview get the selected all the values and assign it controls which are out of gridview and change Text of the Button as "Update"
so you can identify that at this time values should be updated.After updation change again text of button as "Add".

Look at here
Your update Button in gridview looks like as
<ItemTemplate>
<asp:Button id="BtnUpdate" runat="Server" Text="Update" CommandName="updateRec" CommandArgument='<%# Container.DataItemIndex + 1 %>' />
</ItemTemplate>

Now Row_Command Event OF gridview
 

if(e.CommandName=="updateRec")
{
int index=int.Parse(e.CommandArgument.ToString());
txtFirstName.Text=((Label)GridView1.Row[index].FindControl("lblFirstname")).Text; // bind first name in lable and find out it and assign value in TextBox
// .......................................same codes for other controls.
//Now your selected values are in controls which is out of gridview
//Change Button Text which is out of gridview to update data

MyButton.Text="Update";
}

Now on Button event, You have to check the text of the Button.If it is "Add",Insert record in database and if it is "Update", Update records
On click of button

Button myButton=(Button)Sender;
if(myButton.Text=="Add")
{
// Insert new records here
}
else if(myButton.Text=="Update")
{
// update records here
//chage Text again so you can add new record.

myButton.Text="Add";
}
  
Click on 'Mark as Answer' if this post is helpful.

ImranKhan pathan
0
impathan
12/28/2007 1:02:54 PM

Is there any way that the outside control (Textbox) can be bound to the Gridviews column. Or for doing this, is there any better way?

For the time being i did this by manually displaying the data using GridView's selected Row.Cell values but want some preferred way.


Regards
Mohsin Shahzad
0
wolfenstein4u
12/28/2007 1:04:02 PM

Yes thats make some sense.

Thanks Imran!


Regards
Mohsin Shahzad
0
wolfenstein4u
12/28/2007 1:18:19 PM

wolfenstein4u:

Is there any way that the outside control (Textbox) can be bound to the Gridviews column. Or for doing this, is there any better way?

For the time being i did this by manually displaying the data using GridView's selected Row.Cell values but want some preferred way.

 

Do you want to bind outer controls with the selected rows values?
see my previous post, I did boud outer controls with selected rows on row_command event.


Click on 'Mark as Answer' if this post is helpful.

ImranKhan pathan
0
impathan
12/28/2007 1:24:28 PM
Reply:

Similar Artilces:

gridview control in another gridview control
Hi ia have a questioni have a gridview control which contains button in one colum.now my question is i need another gridview to be placed in the  first gidviewso that when i click on the button the second gridview will populate the data.now my question is how to place second gridview in first gridview.or is there any approach like first grid itself acting as parent and child.please help me  Hi sirikalavalapalli:                I think nested gridview will help you. Check this link and it will show you how...

Gridview control embedded in another gridview control
I am writing an ambulance crew scheduling application on the web and I need some help completing the last part.  I have an access database that has three tables: user table, shift table (describing the shifts available), and a schedule table (that stores shift by shift_id and user by user_id).  I have a gridview control that will display the available shifts but I cannot get the embedded gridview control that will display the user that is signed up for each shift to display because I cannot figure out how to use the OnRowDataBound method.  I need a simple VB example of how to...

There is a Gridview Control in the tmplate field of another GridView Control.
    For instance,a gridview displays the information of the  students in a class.A table is recording the information except their mark.There is another table recording the mark of the students whose foreign key is the primary key of the previous table.   string strSQLconnection=".................."; SqlConnection sqlCononection=new SqlConnection(strSQLconnection); SqlCommand sqlCommand=new SqlCommand("select * from stuendent where classID=1",sqlConnection); SqlConnection.Open(); SqlDataReader reader=sqlCommand.ExecuteReader(); GridVie...

Control to Compare
My Problem is this. I have one textbox control outside grid view control and another textbox control inside the gridview control . My question is, how to compare these two textbox controls using compare validator ?   Thanks in advance.   Suresh Hello Suresh, I am afraid you cannot use compareValidator, it cannot find the TextBox control in the GridView, but you can choose CustomValidator, it works. JessicaJessica CaoSincerely,Microsoft Online Community Support“Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a ma...

How to control the position of Gridview when Gridview is dynamically binding
Hello:  I have one Gridview on the left side. Each field has the hyperlink. When uses click the link, I need to pass this string to another dynamic Gridview control. This Gridview control is needed to dynamically bind. This Gridview control is need to be stay on the right side of the first Gridview.  Here is my dynamic binding Gridview code: TableRow row = new TableRow();tbl.Rows.Add(row);        ……….. GridView gv1 = new GridView();       ……cel1.Controls.Add(gv1); Here is my questions. How I could p...

How can I control the width of a column in the GridView control.
From searching I see mention of ways to do it before the controls are bound. Is there a simpler way? If not, could someone explain to me how I need to go about it?Here is the code: <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id"        DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display."        OnSelectedIndexChanged="GridView1_SelectedIndexChanged">   &nbs...

Trying to use the FAQ " Sorting and paging in the GridView control when not using data source controls "Sorting and paging in the GridView control when not using..."
and I am not getting the results I had hoped for.  I keep getting a "Compiler Error Message: CS0123: No overload for 'AdhocJobGridView_PageIndexChanged' matches delegate 'System.EventHandler'".   Here is my event handling... protected void AdhocJobGridView_PageIndexChanged(object sender, GridViewPageEventArgs e){ try { AdhocJobGridView.DataSource = wsBaseInfoArray; AdhocJobGridView.PageIndex = e.NewPageIndex; AdhocJobGridView.DataBind(); }catch (Exception ex) {throw ex; }   Here is my aspx... <asp:GridView ID="AdhocJobGridView...

Getting the control id of a control inside gridview control
 uhmm.. a little bit confusing regarding my subject because i dont know how to say it...by the way my problem is how can i get the id of a control (e.g. textbox) inside the gridview... and the textbox is in the templatefield... is there any way i can get its id??  hoping i could get a reply as soon as possible... Regards,MhaeyPlease remember to click “Mark as Answer” on the post that helps you.. =) What do you want's to do by getting the id of the Text box? Do you want's to find particular Textbox with certain id ? Kamran ShahidSr. Software Engineer(MCP,MCAD.net,MC...

Updating and binding control to other controls within the same row of a GridView
HiIn the EditTemplate of my GridView I show 2 DropDownLists. When the user selects the first dropdownlist, I need it to update the contents of the second dropdownlist. I have my Subs that do this fine when not inside the GridView, but what is the correct way to do it whilst they are in the GridView?This is my current attempt that returns the error 'Object reference not set to an instance of an object'. I presume its related to correctly targeting the DropDownList in question? This is my GridView:<asp:GridView ID="GridView1" runat="server"  &...

binding specific column to gridview control..
Hi,While binding data to grid view i want only some specific column tobe displayed in grid view.. i am fetching some column from sql datatbase and from that columns i want to display only specific column in grid view.. i have used dataset for fetching data from database... and also i want one clumn as hyperlink in gridview when i click on that hyperlink i want other vaues of that row passed tp target page..please tell me  how to do this..  .. waiting for immediate reply...Thanks and Regards,  u can use a template column containing label and assign its value to the specified ...

help me! WHY CAN THE TOP GRIDVIEW DETECT CONTROLS BUT THE SECOND GRIDVIEW NOT DETECT CONTROLS?!
Hi guys, two gridviews, same page, but one cant define paramters, the other one can.  the one that works is the first example, the one that doesnt work is the second example.  what is the difference? if you could highlight why example two doesnt detect contorls that would be great!!! example one <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2&qu...

Help Req: !!! :- On Disabling Controls Present inside a Gridview control
Hi All, We have A requirement Where we have disable controls inside a grid.These controls can be textbox, DropDownlist (in TemplateField), ComandField present inside the grid.We have to call a generic method for doing the same .(since it can be done for multiple grid.) PFB the code snippet we use. Which disables all the controls inside the page.The bolded part of the code is used to loop inside a grid view.(Not Working.)Is this ideal way to deal with the requirement.Or can someone suggest be a better way.        public void DisableMe(Page p1, st...

Can I populate a Gridview outside of the Gridview using my own edit controls ?
I want to be able to populate a GridView control through some edit controls that willbe displayed above my GridView control. Is their a way to do this without using a DetailsView control ? (Refer to the following article) http://www.dotnetbips.com/articles/c1e0ca90-5f5d-47aa-a739-492b562e810a.aspx Or can I have my own edit controls seperately from the GridView control? Actually, all you need to do is to put some textboxes and button. Than on button click insert that data in database and bind data to your gridviewagain. __Please mark post as answer if it helps, if not come back and a...

binding specific column to gridview control.. #2
 Hi,While binding data to grid view i want only some specific column to be displayed in grid view.. i am fetching some column from sql datatbase and from that columns i want to display only specific column in grid view.. i have used dataset for fetching data from database... and also i want one column as hyperlink in gridview when i click on that hyperlink i want other values of that row passed tp target page..please tell me  how to do this..  .. waiting for immediate reply...i am taking data in dataset and binding that dataset to gridview my code is as follows:SqlConnec...

Web resources about - Binding GridView Columns with controls outside the GridView - asp.net.presentation-controls

GridView SelectedItem Binding Gotcha in WinRT
Last night when I was doing some WinRT hacking I was trying to setup databinding to the selected item in the GridView control and I ran into ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Advanced Search Gridview Latest News Releases All ...

CNW Group
... Services Beyond the Wire About CNW my CNW CNW Access CNW Directories Financials Webcasts Events my CNW All News Releases Advanced Search Gridview ...

CNW Group
Home Services Beyond the Wire About CNW Financials Webcasts Events My CNW All News Releases Add a Filter Gridview Latest News Releases All Today ...

New CmdLets of Powershell 2.0
New CmdLets of Powershell 2.0

Price Drop: Softbox
... objects- create product reflection- changing the background with something more interestingUse it as:- softbox- honeycomb softbox- gridview ...

Profile.aspx: ASP Alliance
.NET,ASP,ASP.NET,SQL,XML,HTML,ADO,ADO.NET,JavaScript,JScript,CSharp,VBScript and VB tutorials from AspAlliance.

Quick Answers - CodeProject
Questions - Free source code and tutorials for Software developers and Architects.; Updated: 25 Oct 2012

DotNetKicks.com - Upcoming stories
DotNetKicks.com is a community based news site edited by our members. It specialises in .NET development techniques, technologies and tools including ...

View Features - ExtendASP
Call 847-681-9827 or Request a Demo View Features Testimonials Pricing About Us Coming Soon ExtendASP exposes every feature, more than any other ...

Resources last updated: 1/20/2016 1:31:13 AM