Asp.net gridview with dropdown: Rowindex is always 0 in SelectedIndexChanged event - c#

I have a problem that's been driving me nuts. Any help would be much appreciated. I have a grid view that displays what research items are assigned to what people. It should be possible to change the assignments using a dropdown. Here's the markup:
<asp:GridView ID="assignmentsGridView" runat="server" AutoGenerateColumns="false" CellPadding="2" Font-Size="Smaller"
OnRowDataBound="assignmentsGridView_RowDataBound" OnRowCommand="assignmentsGridView_RowCommand">
<Columns>
<asp:BoundField HeaderText="Ticker" DataField="Item" />
<asp:BoundField HeaderText="Name" DataField="Name" />
<asp:TemplateField HeaderText="Assignment" ItemStyle-HorizontalAlign="Center" ControlStyle-Font-Size="Small">
<ItemTemplate>
<asp:DropDownList ID="assignmentDropDown" runat="server" Visible="true"
OnSelectedIndexChanged="assignmentDropDown_SelectedIndexChanged" AutoPostBack="true" >
<asp:ListItem Text="Joe" Value="Joe"></asp:ListItem>
<asp:ListItem Text="Aron" Value="Aron"></asp:ListItem>
<asp:ListItem Text="Frank" Value="Frank"></asp:ListItem>
<asp:ListItem Text="Ross" Value="Ross"></asp:ListItem>
<asp:ListItem Text="Alex" Value="Alex"></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField HeaderText="Analyst Complete" DataField="AnalystComplete" ItemStyle-HorizontalAlign="Center" ControlStyle-Font-Size="Smaller"/>
<asp:TemplateField HeaderText="Mark Complete" ControlStyle-Font-Size="Smaller">
<ItemTemplate>
<asp:Button ID="completeButton" runat="server" Text="Incomplete" CommandArgument='<%# Eval("Item") %>'
CommandName="Complete" Font-Size="Smaller" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
I want to update the database when the user changes the SelectedIndex of the dropdown. I'm handling that here:
protected void assignmentDropDown_SelectedIndexChanged(object sender, EventArgs e)
{
if (Session["IsCompany"] == null)
{
Session["IsCompany"] = assignmentsDropDown.SelectedValue == "Company";
}
bool? isCompany = Session["IsCompany"] as bool?;
int isCo = (isCompany == true) ? 1 : 0;
DropDownList ddl = sender as DropDownList;
GridViewRow gvr = ddl.NamingContainer as GridViewRow;
//ri is always 0!
int ri = gvr.RowIndex;
gvr = (GridViewRow)(((Control)sender).NamingContainer);
//ri is always 0!
ri = gvr.RowIndex;
gvr = ((GridViewRow)ddl.Parent.Parent);
//ri is always 0!
ri = gvr.RowIndex;
string selAnalyst = ddl.SelectedValue;
//selAnalsyt always = initial value!
selAnalyst = ddl.SelectedItem.Value;
//selAnalsyt always = initial value!
string ticker = gvr.Cells[0].Text;
//ticker always is first data row
}
As you can see in the comments, no matter what row I click, the GridViewRow associated with the sender argument is always the first row. Also, the selected value of the dropdown is always its initial value, not the value selected by the user that fired off the SelectedIndexChanged event.
I've searched for a solution to this problem online and found that it is often caused by (1) the databind event getting fired on postback and (2) duplicate rows in the source data. I have checked for duplicate data and solved that problem and put primary keys on the appropriate table. I'm also making sure not to rebind the data on postback. Here's the Page_Load method:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.User.Identity.IsAuthenticated)
{
FormsAuthentication.RedirectToLoginPage();
}
else
{
string userName = Page.User.Identity.Name;
if (Session["UserMod"] == null)
{
this.userMod = new userModel(userName);
}
else
{
this.userMod = Session["UserMod"] as userModel;
}
if (!IsPostBack)
{
getPeopleList(userName);
getTickerList(userName);
if (this.userMod.IsResearchAdmin)
{
getAdminList();
}
else
{
assignmentsDropDown.Visible = false;
assignmentsGridView.Visible = false;
assignmentsButton.Visible = false;
assignmentsLabel.Visible = false;
addTextBox.Visible = false;
Image1.Visible = true;
analystDropdown.Visible = false;
}
}
}
}
I've got a RowDataBound method as well which sets the selected value of the dropdown for each row. When debugging, I have verified that the method is only running on the initial page load, not after the postback from SelectedIndexChanged. I was using an Update Panel as well, but removed that while trying to debug this.
I'm all outta ideas now, so I'm open to any suggestions. Thanks in advance

It looks like I've discovered an odd idiosyncrasy of asp.net. I had the following code in the RowDataBound method:
if (IsCompany)
{
e.Row.Cells.Remove(e.Row.Cells[1]);
}
I removed this code and the dropdown SelectedIndexChanged method now works correctly. All 3 methods of getting the parent GridViewRow of the dropdownlist are working after changing the RowDataBound method so that it does not remove any cells in the gridview.
I now believe that adding or removing cells during databinding causes unexpected problems with the SelectedIndexChanged event for dropdowns within GridViews. Here is the full code of the RowDataBoundMethod:
protected void assignmentsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (Session["IsCompany"] == null)
{
Session["IsCompany"] = entityDropDown.SelectedValue == "Company";
}
bool? isCompany = Session["IsCompany"] as bool?;
bool IsCompany = (bool)isCompany;
TableCell cell;
if (e.Row.RowType == DataControlRowType.DataRow)
{
cell = e.Row.Cells[0];
HyperLink link = new HyperLink();
if (IsCompany)
{
link.NavigateUrl = "~/CompanyPage.aspx?Ticker=" + cell.Text;
}
else
{
link.NavigateUrl = "~/PeoplePage.aspx?PersonId=" + cell.Text;
}
link.Text = cell.Text;
cell.Controls.Clear();
cell.Controls.Add(link);
/* with this code included, I experience problems with the SelectedIndexChanged event of the dropdown
if (IsCompany)
{
e.Row.Cells.Remove(e.Row.Cells[1]);
}
*/
cell = e.Row.Cells[2];
var dd = e.Row.FindControl("assignmentDropDown") as DropDownList;
string assignment = ((DataRowView)e.Row.DataItem)["Assignment"].ToString();
foreach (ListItem li in dd.Items)
{
if (li.Value == assignment)
{
li.Selected = true;
break;
}
}
cell = e.Row.Cells[4];
if (cell.Text == "False")
{
//"completeButton"
var cb = e.Row.FindControl("completeButton") as Button;
cb.Enabled = false;
cb.Visible = false;
}
else
{
((Button)cell.FindControl("completeButton")).CommandArgument = e.Row.RowIndex.ToString();
}
}
}
If someone could confirm that removing cells inside rowdatabound causes problems with the selected index change event in asp.net I'd appreciate it.

Related

C# ASP.NET Add "remove button" to List in grid-view

I am making a checkout program using C# and ASP.NET (because it has to work for offline(as a backup checkout register)).
I got the list working into a GridView but i want to make per added list added to the GridView that it will automatically make a "remove button".
I have tried to find in on the internet but most are database related(removing an item in database) and not just removing a row in a GridView.
what i have:
public static List<KassaItem> KassaList = new List<KassaItem>();
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Focus();
}
public string Connection(string eannr)
{
// connection stuff here
}
public class KassaItem
{
public string EanNr { get; set; }
public string zoekName { get; set; }
public int Quantity { get; set; }
public double Price { get; set; }
public KassaItem(string eanNr,string zoekname, int quantity, double price)
{
EanNr = eanNr;
zoekName = zoekname;
Quantity = quantity;
Price = price;
}
}
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
double TotalPrice = 0;
string zoekfunctie = Connection(TextBox1.Text);
string[] zoekSplit = zoekfunctie.Split('-');
string zoekNaam = zoekSplit[1];
double Prijs = Convert.ToDouble(zoekSplit[0]);
List<KassaItem> KassaNew = new List<KassaItem>();
bool isNew = true;
if (TextBox1.Text != "")
{
foreach (var KassaItem in KassaList)
{
if (TextBox1.Text == KassaItem.EanNr)
{
KassaNew.Add(new KassaItem(KassaItem.EanNr, KassaItem.zoekName, KassaItem.Quantity + 1, KassaItem.Price + Prijs));
isNew = false;
}
else
{
KassaNew.Add(KassaItem);
}
}
if (isNew)
{
KassaNew.Add(new KassaItem(TextBox1.Text, zoekNaam, 1, Prijs));
}
KassaList = KassaNew;
GridView1.DataSource = KassaList;
GridView1.DataBind();
foreach(var item in KassaList)
{
TotalPrice += item.Price;
}
// here i want to make a button
foreach(var item in KassaList)
{
Button RemoveButton = new Button();
RemoveButton.Text = "remove product??";
RemoveButton.ID = "ButtonRemove_" + Item.EanNr;
}
}
TextBox1.Text = "";
TextBox1.Focus();
TotalItems.Text = TotalPrice.ToString();
}
What I want is basically:
how to make a "button" that is assigned to the row when, the row is created to delete the row when it is clicked.
P.S.
I'm also happy if i get a link to a documentation that i might not have seen/missed.
I wish you a happy new year in advance!
Ok, so we have a grid view. We want to drop in a simple plane jane asp.net button, and when we click on this, we delete that row. But we do NOT YET delete from the database. And we could of course have a button below the gv that says "save changes" and then the deletes would actually occur against the database.
So, lets do the first part. GV, load with data, add delete button.
So we have this markup:
<asp:GridView ID="GHotels" runat="server" CssClass="table"
width="50%" AutoGenerateColumns="False" DataKeyNames="ID" >
<Columns>
<asp:BoundField DataField="FirstName" HeaderText="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName" />
<asp:BoundField DataField="HotelName" HeaderText="HotelName" />
<asp:BoundField DataField="City" HeaderText="City" />
<asp:BoundField DataField="Description" HeaderText="Description" />
<asp:TemplateField HeaderText = "Delete" ItemStyle-HorizontalAlign ="Center" >
<ItemTemplate>
<asp:Button ID="cmdDelete" runat="server" Text="Delete"
CssClass="btn"
/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Button ID="cmdSave" runat="server" Text="Save Changes" CssClass="btn" />
<asp:Button ID="cmdUndo" runat="server" Text="Undo Changes" CssClass="btn"
style="margin-left:25px" />
I dropped in two buttons below the GV - we deal with those later.
So, now here is our code to load the GV - NOTE very careful how we persit the table that drives this table. So we can load the table from database, and now our operations can occur against that table that drives the gv - but we do NOT send the changes back to the database (changes in this case = deletes - but it could be edits or additions if we want - and that's easy too!).
Ok, so our code is this:
DataTable rstData = new DataTable(); // data to drive grid
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadData();
Session["rstData"] = rstData;
LoadGrid();
}
else
{
rstData = Session["rstData"] as DataTable;
}
}
void LoadData()
{
using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.TEST4))
{
string strSQL = "SELECT * FROM tblHotels ORDER BY HotelName";
using (SqlCommand cmdSQL = new SqlCommand(strSQL, conn))
{
conn.Open();
rstData.Load(cmdSQL.ExecuteReader());
}
}
}
void LoadGrid()
{
GHotels.DataSource = rstData;
GHotels.DataBind();
}
}
and now we have this:
So, now lets add the code behind event stub for the delete button:
We can't double click on the button to jump to the click code behind event stub, so we have to type into the markup the onclick= (note VERY close how you are THEN offered to create a click event for the button. You see this:
So, we choose create new event (don't look like much occures, but we can now flip to code behind - and you see our event stub created for us.
Ok, so all we have to do is delete (remove) the row from the gv. The code looks like this:
protected void cmdDelete_Click(object sender, EventArgs e)
{
Button btn = sender as Button;
GridViewRow gRow = btn.NamingContainer as GridViewRow;
int? pkID = (int?)GHotels.DataKeys[gRow.DataItemIndex]["ID"];
// find row and delete
DataRow[] DelRow = rstData.Select("ID = " + pkID);
DelRow[0].Delete();
LoadGrid();
}
Now, the delete code was a bit messy. In MOST cases, I could have done just this:
rstData.Rows[gRow.DataItemIndex].Delete();
However, when you delete from the table, we NOT YET done a rstData.AcceptChanges. So the row sync between table and Gv gets messed up.
Now I COULD DO a accept changes to the table, but if we do that, then we LOSE the deleted rows - and we NEED that for the single final save button that would actually commit and do the deletes. So we use find on the table by PK row id, and we eliminate this issue but MORE important PERSERVE the deleted rows in that data table. (by NOT doing accept changes). And we do that, since now we can send with ONE SINGLE update to the database, the deleted rows. However, as noted, the problem is that when you delete the rstData row, but not accept changes - it STILL exists, an thus when we feed to GV, those deleted rows don't show - but the data index is still set, but dataindex at that point does not match rows from the table.
So, now when we click on the delete button, the row will be deleted. But we not deleted the row from the database.
The undo command? Well, it would just run the same code we have on first page (postback = false) code, and thus we could un-do deletes with great ease.
As you can see - not a lot of code here.
And if you wish, I can post the actual delete code we would use for this to commit the deletes to the database. With above, it is only ONE update command to send the deletes to the database.
Thanks Albert but got a way answer to this.
C#:
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
List<KassaItem> KassaNew = new List<KassaItem>();
TableCell NR = GridView1.Rows[e.RowIndex].Cells[1];
string eanrNR = Convert.ToString(NR.Text);
string zoekfunctie = Connection(eanrNR);
string[] zoekSplit = zoekfunctie.Split('-');
string zoekNaam = zoekSplit[1];
double Prijs = Convert.ToDouble(zoekSplit[0]);
GridViewRow row = GridView1.Rows[e.RowIndex];
TableCell cell = GridView1.Rows[e.RowIndex].Cells[3];
int quantity = Convert.ToInt32(cell.Text);
int newquantity = quantity - 1;
if (newquantity == 0)
{
KassaList.RemoveAt(e.RowIndex);
}
else
{
foreach (var KassaItem in KassaList)
{
if (eanrNR == KassaItem.EanNr)
{
KassaNew.Add(new KassaItem(KassaItem.EanNr, KassaItem.zoekName, newquantity, KassaItem.Price - Prijs));
}
else
{
KassaNew.Add(KassaItem);
}
}
KassaList = KassaNew;
}
foreach (var item in KassaList)
{
TotalPrice += item.Price;
}
GridView1.DataSource = KassaList;
GridView1.DataBind();
TextBox1.Text = "";
TextBox1.Focus();
TotalItems.Text = TotalPrice.ToString();
}
protected void GridView1_RowDeleted(object sender, GridViewDeletedEventArgs e)
{
}

How to hide image button along with row header in grid view

I am trying to hide a column in grid based on user role type
this is my c# code
protected void gvBudget_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (user == "1")
{
ImageButton imgBtn = (ImageButton)e.Row.FindControl("imgDelete");
imgBtn.Visible = false;
}
}
}
catch (Exception ex)
{
log.Info("Error in gvBudget_RowDataBound() " + ex.ToString());
}
}
this is the html page
<asp:TemplateField HeaderText="Delete" HeaderStyle-CssClass="grid_header_text">
<ItemTemplate>
<asp:ImageButton ID="imgDelete" runat="server" CommandName="DEL" ImageUrl="~/Image/delete.gif"
OnClientClick="if(confirm('Budget List Summary \n\n Selected record will be deleted please confirm')==false){event.returnValue=false;return false;}else{return true;}" TabIndex="18" ToolTip="Delete" />
</ItemTemplate>
<HeaderStyle CssClass="grid_header_text"></HeaderStyle>
</asp:TemplateField>
i am able to hide the button, but unable to hide the row header or the column.
Based on your error message that you're logging, I am assuming that you have a GridView. If that is the case, couldn't something like this work?
gvBudget.Columns[0].Visible = false;
Ok, the problem is if we JUST hide the control, the column still renders. The key Rosetta stone here was that in fact your column control WAS hiding.
Say we have this:
And my code to hide the link button is say is this:
Dim lb As LinkButton = gv.FindControl("btnLNK")
lb.Visible = False
Then we get this:
So it DOES hide the control "in side" the column, but not the whole column.
So, you have to hide the cell, say like this:
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(4).Visible = False
End If
But note how his ONLY hide the data, not the header.
So we have to hide both header, and the data, say like this:
If e.Row.RowType = DataControlRowType.DataRow Or
e.Row.RowType = DataControlRowType.Header Then
e.Row.Cells(4).Visible = False
End If
And we get this:

Datagrid ItemCommand event not firing

I am still a novice with asp.net, so I'm sure there are better ways to do some of this...
I want to allow a user to enter a date, and then execute an SQL query against a database to return all records matching that date. I want to display those records, and allow the user to select one for additional processing. It seemed like the DataGrid with a column of Pushbuttons was a good choice. In fact, I've done this before, but it those cases there was no user interaction involved. The page just ran a fixed SQL query. With what I'm doing now, the data is displayed as I want, but the Pushbuttons aren't working...the ItemCommand event doesn't fire.
I've read a lot of threads about the ItemCommand event not firing, but I still can't get this to work. My understanding is that I need to bind the DataGrid while not in a Postback, and I think my code does that. When I debug the Page_Load event, I can see that the code inside if (!IsPostBack){} is running, and the session variables have the expected data.
On the page that hosts the DataGrid, I have a 'Find' button that executes a SQL query against a database. The query uses a date entered into the textbox that is on that page. In the 'Find' button click event, I store the results of the query (a DataTable) in a session variable, then do a Redirect to re-load the page.
Once the page reloads, the session variables contain my expected data and the data is displayed in the DataGrid, along with the Pushbuttons. When I click any of the buttons in the DataGrid, the contents of the DataGrid disappear and the ItemCommand event does not fire.
Here's the definition of the DataGrid (updated to include the button):
<asp:Panel runat="server" ID="pnlSelect" HorizontalAlign="Left" Visible="true" style="margin-top:10px" >
Please select a participant.
<asp:DataGrid runat="server" ID="grdItems" AutoGenerateColumns="true" BorderColor="black" BorderWidth="1" CellPadding="3" style="margin-left:2px; margin-top:6px" OnItemCommand="grdSelect_ItemCommand" >
<Columns>
<asp:ButtonColumn HeaderStyle-HorizontalAlign="Center" ButtonType="PushButton" Text="Select" HeaderText="Select" CommandName="Select" >
<ItemStyle Width="60px" HorizontalAlign="Center"/>
</asp:ButtonColumn>
</Columns>
</asp:DataGrid>
</asp:Panel>
Here's the Page Load code (unneeded code-behind stuff is commented out):
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["y"] != null)
{
txtFind.Text = Session["x"].ToString();
DataTable table = Session["y"] as DataTable;
Session.Remove("x");
Session.Remove("y");
if (table != null)
{
/*
ButtonColumn buttonColumn = new ButtonColumn
{
HeaderText = "Select",
Text = "Select",
CommandName = "Select",
ButtonType = ButtonColumnType.PushButton,
};
grdItems.Columns.Add(buttonColumn);
foreach (DataColumn c in table.Columns)
{
BoundColumn column = new BoundColumn
{
HeaderText = c.Caption,
DataField = c.Caption,
ReadOnly = true
};
grdItems.Columns.Add(column);
}
*/
grdItems.DataSource = table;
grdItems.DataBind();
}
}
}
}
Here's the relevant 'Find' button event code. I can't post the details of the sql query text, but that part does work and the DataTable does contain the expected data:
DataTable table = DatabaseHelper.FindBySQL(sqlText);
if (table != null && table.Rows.Count > 0)
{
Session["x"] = searchtext;
Session["y"] = table;
Response.Redirect(Request.RawUrl, true);
}
And this the ItemCommand event. I place a breakpoint on the first line, and the debugger never hits it.
protected void grdItems_ItemCommand(object source, DataGridCommandEventArgs e)
{
string item = "";
switch (e.CommandName.ToLower())
{
case "select":
item = e.Item.Cells[1].Text.Trim();
//todo: handle the selected data
break;
}
}
Thanks for any thoughts.
Don

How to get an unselected value from a gridView

i need to be able to delete a record from a GridView, but in order to do so, i need to to a method on the .cs file. The thing is that i have other tables that have the ID of a train associated with it, so i need to display an error message if the delete command fails. My problem is that, i can only delete a record when that record is selected.
(GridView2.SelectedDataKey). I want to be able to delete it when it's not selected.
Something like GriView2.Datakey .....
aspx page:
<LinkButton ID="LinkButton3" runat="server" CausesValidation="False"
CommandName="" Text="DELETE" OnClick ="del" >
.cs code:
protected void del(object sender, EventArgs e)
{
string DeleteSql = "DELETE FROM [Trains] WHERE [ID_Train] = #ID_Train";
SqlCommand com = new SqlCommand(DeleteSql, Connection);
String key = GridView2.SelectedDataKey["ID_Train"].ToString();
try
{
com.Parameters.AddWithValue("#ID_Train", key);
cn.Open();
com.ExecuteNonQuery();
cn.Close();
Response.Redirect("Trains.aspx");
}
catch (Exception)
{
Label5.Text = "Error";
Label5.Visible = true;
}
}
Assuming you have a template construct similar to this:
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
AND you have a Delete command in your SqlDataSource, you can process the delete command and access the datakeys in the RowCommand Event like this (Note I converted this from VB so the C# might be off, but you get the idea):
private void GridView1_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e) Handles GridView1.RowCommand
{
if( e.CommandName == "Delete" ) {
string TrainID = GridView1.DataKeys(e.Row.RowIndex).Values("ID_Train");
integer rc = 0;
GridView1.DeleteParameters.Clear();
GridView1.DeleteParameters.Add("Train_ID", TrainId); // Adjust as necessary
try{
rc = GridView1.Delete();
if( rc == 1) {
// Deleted
} else {
// Not Deleted
}
}
catch() {
Label5.Text = "Error";
Label5.Visible = true;
}
}
}

how to find datagrid row in asp.net 2.0 C#

I am using dot net 2.0 and c#.
I have a requirement where i have to find rows of datagrid and pass then as an argument in a function, could you please provide me code for findind a row in datagird. Thanks
You can try with ItemDataBound event on your datagrid
void Item_Bound(Object sender, DataGridItemEventArgs e)
{
if((e.Item.ItemType == ListItemType.Item) ||
(e.Item.ItemType == ListItemType.AlternatingItem))
{
var control = (Label)e.Item.FindControl("YourLabel");
control.Text="pass your value";
}
}
<asp:DataGrid id="DataGrid1"
runat="server"
AutoGenerateColumns="False" OnItemDataBound="Item_Bound">
<Columns>
<asp:TemplateColumn HeaderText="Sample">
<ItemTemplate>
<asp:Label id="YourLabel" runat="server"/>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
You could loop your gridview / datagrid rows and do whatever you want when some criteria matches what you are looking for.
foreach (GridViewRow gvr in gvDemo.Rows) {
if (gvr.DataItem != null) {
//depending on how or what you want to find
//check a key
if (gvDemo.DataKeys[gvr.RowIndex].Values[0] == "xx") {
}
//or a field value
if (gvr.Cells[0].ToString() == "123") {
}
//or first cast your row data item back to a known class
CarBrand carBrand = (CarBrand)gvr.DataItem;
if (carBrand.Name == "Porsche") {
//
}
//or pass the whole row to whatever function
if (xx == yy) {
DoSomething(gvr);
}
}
}
You just put the datagrid to the ItemDataBound and and calling the Event ItemDataBound_click
Write this
string rownumber = e.Item.FindControl("your id for the label") As Label
and use after converting the equivalent data type you use this as a parameter.

Categories

Resources