Asp.net - Retrieving A Row From The GridView
Jan 12, 2011I want to retrieve a cell from the selected row in GridView. Please tell me how to do tanks in advance
View 2 RepliesI want to retrieve a cell from the selected row in GridView. Please tell me how to do tanks in advance
View 2 RepliesI have a code to pass the querry from a one page that has a gridview hyperlink but what i didn't know is how to retrieve it..
Here is my code i hope you could help me fix this one.. thnx
Have a nice day ^^,
Default1.aspx(Gridview1) page:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" HorizontalAlign="Center" Width="570px"
AllowPaging="True" CellPadding="4" ForeColor="#333333" GridLines="None">[code].....
I was given help in a previous topic located here: Accessing Gridview In Another Form In this topic I had gridview rows that are selectable and a search window that returned search results. We found a way for me to select a row in the parent window of the search one. My issue now is that when the parent windows gridview is sorted, the function no longer selects the correct row. I was wondering if there was any way to access the gridviews sort expression and direction, or some other way I can do this so it accounts for sorting. Relavent code is as follow: This is in my parent window
<script type = "text/javascript">
function selectRow(index)
{
//Retrieve a reference to the table that represents the GridView
var gridView = document.getElementById('<%=gvSideList.ClientID%>');
if(gridView)
{
//If able to get a reference to the table representing the GridView...
var doPostbackArgument='Select$'+index;
__doPostBack('<%=gvSideList.ClientID%>',doPostbackArgument);
}
}
This is in the child window
<script type = "text/javascript" >
function selecttherow(index)
{
window.opener.selectRow(index);
}
</script>
protected void gvresults_SelectedIndexChanged(object sender, EventArgs e)
{
//declare variables
GridViewRow row;
int index;
int id;
//retrieve index, row, and id from gvresults
index = gvresults.SelectedIndex;
row = gvresults.Rows[index];
id = Convert.ToInt32(row.Cells[5].Text);
//fill a datatable from general with id's for selection
SqlCommand cmd = new SqlCommand("SELECT ID FROM General", csbg);
cmd.Parameters.AddWithValue("@id", id);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
//loop through the dt and find the index of the matching id from the search window
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows[i]["ID"].Equals(id))
{
//execute script to select the matching row in the dataentry page
string script = "";
script += "selecttherow(";
script += i;
script += ");";
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "selecting", script, true);
break;
}
}
}
Let me know if you need me to further clarify anything.
Tried this but it doesn't work.
[Code]....
Retrieving datakey value in gridview?
After i retrieved a set of datatable from database, i need to edit the rows value before binding to the gridview. for example, a set of datatable is retrived from database.
eg: [userid], [userEmail] --> 1 , james@hotmail.com
i would like to change "james@hotmail.com" to "james" then bind it to gridview. Every rows of [userEmail] will be separated with the mail extension (@hotmail.com) ... how should i do..?
I have a button on the page and a gridview with checkboxes on the first column. The gridview is bound to a List. On buttonClick, I need to retrieve the underlying bound data item (MyEntity) for each selected row. How can I do this? I can't simply recreate MyEntity based on the gridview columns, because I am not displaying all the fields of MyEntity. I need a way to get a hold of MyEntity based on the key (MyEntityId).
View 2 RepliesI have a GridView with a checkbox for the user to select different categories. I am trying to retrieve the CategoryID associated with each row when the user clicks next, however I keep getting an error that tells me the selected index cannot be negative or out of range.
Here is my function
[Code]....
How do I retrieve the CategoryID of the row as an Integer value?
I'm using a file upload control to save the documnets ina file server and i'm storing the url for the docs in database.
In a grid i'm binding the url to a hyperlink field. But the link is not working. The document is not openeing. Is this the correct way to do?
If the file is stored in a local machine it is openeing but if i store it in some fileserver it is unable to open.
I have a gridview control, I have 3 BoundField columns(Question, Answer, row_id) and 1 TemplateField column(Translate) in which i have textbox. I have more than 50 records and i have enabled paging. I have a button control after gridview. On Clicking the button control i need to extract the text from all the textbox fields and from row_id column.
How to retrieve taxt from all textboxes on buttonclick event
My gridview has a dropdownlist when the user clicks "Edit". my question is: How to I retrieve the value of the cell that contains a dropdownlist (when the user clicks on "Select")?
I am able to retrieve the information from the cell that has a textbox (textbox is displayed ONLY when the user clicks on Edit). But when I try to retrieve information from any cells that has a dropdownlist (dropdownlist is displayed ONLY when the user clicks on Edit), it comes up blank.
In order to retrieve the cell I have used the following below:
[code]....
i am currently facing some problem retrieving image for display on a gridview control. the Image data type in the data table is "image". the data that is stored inside the database is in this format "<Binary data>". may i ask if it is possible tojust retrieve a image data of this format and display in the gridview? or do i need to store the image in a image folder for retrieval?
View 3 RepliesI have encountered the task of saving an image to a MsSQL Server Database. (Although I haven't even managed to do it yet).
But anyways I need to link this image from the MsSQL Database to Gridview. Can this be done ?
On my webpage, jobs.aspx, I have a gridview which is populated from my database. I would like it so that when a row in the gridview is clicked, the ID of the row from my database can then be passed through as a query string to a second webpage, details.aspx, where more information about what was clicked on will be displayed.
I'm confident about being able to pass the query string, I just need help with getting the corresponding row's data ID from my database and making the gridview click-able, which will be the interaction which specifies which ID to be retrieved.
I have a search option which a person can use a multi select listbox. I have it coded so it would loop through to see if its selected or not. I also have a stored procedure where the sql statement is coded for the select statement. For some reason, its not populating my gridview. Where am I doing wrong? Below is the code and stored procedure.
[Code]....
[Code]....
I've created a data bound gridview to a SQL database. I am retrieving the data with a simple select for a specific date, and then populating my gridview. The one caveat is that I have added a second header row to my gridview, and then I am hiding parts of another row that was retrieved to only populate the main header row. I believe that this is causing my issue. However, when I step through the code it appears that my ids are proper (the first row has an id of 0, etc....). However, when I check the checkbox in row 4, the actual data from row 3 is being pulled out of the gridview.
[code]...
iam using an empty div in which i am assigning values through an external javascript via ajax call iam also using an fck editor what i want to do using an internal javascript i want to set the contents of that div in the textarea of fckeditor but in the internal javascript when iam accessing the contents of that div then it is showing "undefined"....
View 1 RepliesIn the following XML structure how do i retrieve the name value and put this into a string? (i am using a XPathNavigator in my method)
<testsystem>
<test>
<name>one</name>
<name>two</name>
<name>three</name>
</test>
</testsystem>
The name will get displayed in the boundcolumn of a datagrid. I was able to get a attribute with a syntax alike this: (but when changing the xml struture it no longer holds a attribute value)
string name = nav.GetAttribute("name", "")
But have no luck getting the value with a nav as of yet. The purpose is to be able to use it for the following object so i can put name into it.
test t = new test() { Name = name, Questions= new List<Questions>() };
On my page, whenever a DetailsView is updated, I must audit the changes into a database. On most pages this works perfect, as there were just textboxes - however on a page I am working on right now, with dropdownlists, my code isn't working.
Basically, what the code does is captures the Updating event of the SqlDataSource, creates a datareader to look at the contents of the row before it's updated, compares the contents to the parameters in the Update query of the SqlDataSource, and if one has changed to log this in a field in the Audit table. An extract of my code is below:
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
{
try {
if (reader[i].ToString() != [code].....
When the control is on a dropdownlist, it seems to never go 'into' the IF even though the fields are different. Do I need to do something special to compare the values of dropdownlists? Note I believe the value is stored as an int in my table.
i've two tables trans-mstr having columns as acc_no_from,date,particular,wd_dt,amt,balance and third_party_transfer(table2) having columns as acc_no_frm,acc_no_to,date,amt.now i wnt to retreive date ,particular,wd_dt,acc_no_to,amt,balance where the acc_no_from in third_party_transfer is equal to the no.entered in the textbox of the webpage.i've used datagrid view to show all this.i'm using c# n sql server2005 in this i'm a beginer
View 1 RepliesERROR: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005
a. I had configured the DCOM on the server
b. If i run the APP on the server with any user: RUN!
c. If i run the APP using the Internet Explorer from any PC everything is fine until i try to call word
e. I have put all template (.dotx) on the server, on the PC and nothing WORD.
I am using office 2003.
the syntax for retrieving a value from a SqlDataSource? I've managed to get it working using numbers to represent the column, but I'd much rather use it's DB name?
[Code]....
//Controller code
CookieContainer cookieContainer = new CookieContainer();
//makes new cookie here
cookieContainer.Add(myCookie);
//Service/Facade code
//myCookie gets passed here
How do I pull the cookie out of the container to make sure it's the right cookie?
Hey there
I have in my database emails table
and i am retrieving all the mails from that table in a string to be included in
message.To.Add()
HOW can i put it in the right format ( separated by Comma and space ) while selecting them from the database?
thank you
in my db i have:
2011-01-28 12:03:46.223
when displaying on .aspx page,
<%# Eval("ModifiedDateTime") == null ? " " : Eval("ModifiedDateTime")%>
it displays on the grid like this:
12/2/2010 8:43:18 AM
how do I format it like the default format shown when I query my db?
I have the following select statement :
string Statement = "SELECT * FROM Car WHERE brand = Bmw;
how is it possble to display the result from the statement, because when i display the result exp: LblInfo.Text = Statement;
The result is : SELECT * FROM Car WHERE Brand = Bmw