473,395 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

read row (1 field) from ItemIndex

I could not fetch "userID/column0" since my datagrid does not usethe DataKeyField (due to reformatting of dates - not shown). TheItemIndex can be located from clicking Edit button. How do Iread the UserID (primary key) after locating the ItemIndex? If Icould get the UserID, this data will be passed into keyValue.

Please show sample as I am new to this stuff. Help isappreciated.

** DataGrid: **
column0 column1
Edit Delete John John English

** end

void DataGrid_Edit(object sender, DataGridCommandEventArgs e) {
if (!isEditing) {
DataGrid1.EditItemIndex = e.Item.ItemIndex;
Response.BufferOutput = true;

int keyValue = e.Item.ItemIndex; //eg 3
string strline ="http://localhost/Quote/Employee/AddUser.aspx?id="+keyValue;

Response.Redirect(strline,true);
}
}

void BindGrid() {
SqlConnection dbConnection = newSqlConnection(ConnectionString);
SqlCommand dbCommand = new SqlCommand();

dbCommand.CommandText = SelectCommand;
dbCommand.Connection = dbConnection;

SqlDataReader dr;
dbConnection.Open();
dr = dbCommand.ExecuteReader();

DataTable dt = new DataTable();
dt.Columns.Add("User ID");
dt.Columns.Add("Username");

while (dr.Read())
{
DataRow r;

r = dt.NewRow();
r[0] = dr["Uid"].ToString().Trim();
r[1] = dr["Username"].ToString().Trim();
dt.Rows.Add(r);
}

DataGrid1.DataSource = dt;
DataGrid1.DataBind();

}

--------------------------------
From: brian yeo

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>rD1M6fA5M0+uIOxVza3MLA==</Id>
Nov 19 '05 #1
0 920

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: George Addison | last post by:
Any idea why I am able to query an Access database OK, but when I try to read field info from records that I know are there I get an error that indicates: "No data exists for the row/column"? ...
1
by: Harry Devine | last post by:
I have a DataGrid that is configured to use the Edit/Update/Cancel concept correctly. My grid shows values from 5 database fields. I only need to update that last 4 fields. The last field is a...
2
by: Joe Au | last post by:
I follow the Walkthrough documented on Visual Studio to create an editable data grid but it does not work on getting the value of the textbox in the data grid. The code is copied here. I mark...
3
by: Adam Knight | last post by:
Hi all, I have asked this question previously, but haven't recieved an adequate answer. I am wanting to output a datalist ItemIndex in a page. I know to display a data item i using <%#...
1
by: fatima.issawi | last post by:
Hello, I am trying to set the value of a hidden field in Javacript in my UserControl. I need to access the value in the code-behind. For some reason, the value of the hidden field never gets...
5
by: Brad Baker | last post by:
I am trying to make a "tabbed" interface by iterating through a dataset with a conditional statement. For example: ...
7
by: trbjr | last post by:
Experts, My javascript application worked well until I upgraded. I use IE 6.0.29 with SP2 installed. My Firefox browser is 2.0.0.4. Prior to upgrade all worked well. Now my application works...
2
lcrutch
by: lcrutch | last post by:
I have managed to get the following segment of code to gather information, from two tables (ItemINDEX, and ItemQOH) and export the results to an Excel file with a predefined name. However, what...
1
by: TomGo | last post by:
Hi All I want to read out the properties of a field by the instance, which is referenced by the corresponding field. I want to read out the attributes. In a class I wrote the following: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.