Gridview DataBinding

Posted by Lokeshbasana under ASP.NET on 3/16/2009 | Views : 1527 | Status : [Member] | Replies : 4
Bind two column field to linkbutton inside gridview

column fiedls are WorkNo and Jobid

<asp:LinkButton ID="lbtnAddProdReport" runat="server" CommandArgument='<%# Eval("WorkNo","Jobid") %>'
oncommand="lbtnAddProdReport_Command">Add Production Report</asp:LinkButton>

Retrieving WorkNo,Jobid in Linkbutton CommandArgument Getting Error

protected void lbtnAddProdReport_Command(object sender, CommandEventArgs e)
{
string woNo = e.CommandArgument.ToString(); //Not retrieving i try to declare string woNo as array but it show error
Response.Redirect("Report.aspx?woNo=" + woNo);
}

Please tell me how to retrieve workno, jobid into linkbutton command




Responses

Posted by: perfectchourasia-9163 on: 11/17/2011 [Member] Starter | Points: 25

Up
0
Down
public void fillgrid()
{
if (Page.Request.QueryString["ID"] != null)
{
int i = Int32.Parse(Request.QueryString["ID"].ToString().Trim());
querystring = i;
string query = "SELECT subtask.ID, subtask.detail, subtask.frequency, subtask.status, subtask.created_at, subtask.Updated_at, subtask.completion_date, subtask.mem_id,subtask.TL_task_id, subtask.member, TL_task.Project_id, TL_task.task_type_id, project.title, Commontask.Title AS Task_title FROM Commontask INNER JOIN TL_task ON Commontask.ID = TL_task.task_type_id LEFT OUTER JOIN project ON TL_task.Project_id = project.id RIGHT OUTER JOIN subtask ON TL_task.ID = subtask.TL_task_id where TL_task_id="+i+"";
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["linkbuilding"].ToString().Trim());
SqlDataAdapter cmd = new SqlDataAdapter(query, con);
DataSet ds = new DataSet();
cmd.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
gridsub.DataSource = ds;
gridsub.DataBind();
}
else
{
Response.Write("Record does not exist in database..");
}
}
}

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Neeks on: 3/16/2009 [Member] Bronze

Up
0
Down
You can use commandname for WorkNo and commandargument for jobid

Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Majith on: 3/17/2009 [Member] Starter

Up
0
Down
Lokesh,

As above Neeks statement refer the code:

<asp:LinkButton ID="LB1" runat="server"  OnCommand="LB1_Command" CommandArgument='<%#Eval("workno")%>'

CommandName='<%#Eval("jobid")%>'>


In Code Behind:

 protected void LB1_Command(object sender, CommandEventArgs e)

{
string s1 = e.CommandArgument.ToString();
string s2 = e.CommandName.ToString();

}


Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lokeshbasana on: 3/17/2009 [Member] Starter

Up
0
Down
thanks Neeks and Majith its working fine.

Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response