WebGird IntializeRow Template Control Properties not availble in Post Back

2 replies. Last post: August 3, 2010 11:15 AM by Douglas Badin
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback

I am using a ColumnType of "Template" for a asp:LinkButton

<ISWebGrid:WebGridColumn
	Name="View_WebGridColumn"
	Bound="false"
	EditType="NoEdit"
	ColumnType="Template"
	Caption=" "
	Width="50px"
>
	<CellStyle ForeColor="Black" />
	<CellTemplate>
		<asp:LinkButton
			ID="PDF_LinkButton"
			runat="server"
			OnCommand="Command_Button_Click"
		/>
	</CellTemplate>
</ISWebGrid:WebGridColumn>

In the WebGrid IntializeRow Server Side Event I set the following for the LinkButton

- Visible
- CommandArgument
- CommandName
- Text
- ToolTip

protected void _WebGrid_InitializeRow(object sender, RowEventArgs e)
{
	if (e.Row.Type == RowType.Record)
	{
		WebGridCellCollection _WebGridCellCollection = e.Row.Cells;

		DataRowView _DataRow = e.Row.DataRow as DataRowView;

		Int32 CallNumber_Int32 = Convert.ToInt32(_DataRow["CALLNUM1"].ToString());
		String AgentCode_String = AgentCode_TextBox.Text;

		LinkButton PDF_LinkButton = (LinkButton) e.Row.Cells[1].GetTemplateContainer().FindControl("PDF_LinkButton");

		PDF_LinkButton.Visible = false;

		PDF_LinkButton.CommandArgument = CallNumber_Int32.ToString();
		PDF_LinkButton.CommandName = "QuoteView";

		PDF_LinkButton.Text = "View";
		PDF_LinkButton.ToolTip = "View Assessment";

		// PDF

		String FileFormat_String = "";
		String FileName_String = "";
		String FilePath_String = "";

		FileFormat_String = Common.ServiceQuoteFileType(); //Desired format goes here (PDF, Excel, or Image)
			FileName_String = Common.ServiceQuoteFileName(AgentCode_String, Convert.ToInt32(CallNumber_Int32));
		FilePath_String = Common.ServiceQuoteFilePath(FileName_String);

		if (File.Exists(FilePath_String))
		{
			PDF_LinkButton.Visible = true;
		}

	}
}

 

The Page renders OK.

However, when I click on the Link Button, the Command_Button_Click Server-Side Event shows the CommandArgument and CommandName being empty.

protected void Command_Button_Click(Object sender, CommandEventArgs e)
{

	switch (e.CommandName)
	{
		case "QuoteView":

...
			break;
	}

}

What am I doing wrong?

How can I access the the CommandArgument and CommandName set in _WebGrid_InitializeRow in the Command_Button_Click Server Side Event?

Thanks,

Doug

All times are GMT -5. The time now is 5:41 PM.
Previous Next